巡检计划修改+删除

highway
wws 1 year ago
parent 411e562832
commit ac2f99c2c7

@ -38,6 +38,7 @@ public class EquPlanController extends BaseController {
/**
*
*
* @param equPlan
* @return
*/
@ -48,6 +49,7 @@ public class EquPlanController extends BaseController {
/**
*
*
* @return
*/
@GetMapping("/getWorkCenter")
@ -76,18 +78,19 @@ public class EquPlanController extends BaseController {
return equPlanService.formatEquItem(equPlanEquList);
}
/**
* list
* @param equEquipment
* @return
*/
@RequiresPermissions("device:plan:list")
@GetMapping("/getEquList")
public TableDataInfo getEquList(EquEquipment equEquipment) {
startPage();
List<EquEquipment> list = equPlanService.getEquList(equEquipment);
return getDataTable(list);
}
/**
* list
*
* @param equEquipment
* @return
*/
@RequiresPermissions("device:plan:list")
@GetMapping("/getEquList")
public TableDataInfo getEquList(EquEquipment equEquipment) {
startPage();
List<EquEquipment> list = equPlanService.getEquList(equEquipment);
return getDataTable(list);
}
/**
*
@ -138,7 +141,7 @@ public class EquPlanController extends BaseController {
@Log(title = "计划", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody EquPlan equPlan) {
return toAjax(equPlanService.updateEquPlan(equPlan));
return equPlanService.updateEquPlan(equPlan);
}
/**
@ -148,6 +151,6 @@ public class EquPlanController extends BaseController {
@Log(title = "计划", businessType = BusinessType.DELETE)
@DeleteMapping("/{planIds}")
public AjaxResult remove(@PathVariable String[] planIds) {
return toAjax(equPlanService.deleteEquPlanByPlanIds(planIds));
return equPlanService.deleteEquPlanByPlanIds(planIds);
}
}

@ -65,4 +65,16 @@ public interface EquPlanDetailMapper {
* @return
*/
List<EquPlanDetail> selectEquPlanDetailByPlanCode(String planCode);
/**
* code
* @param planCode
*/
void deleteEquPlanDetailByPlanCode(String planCode);
/**
*
* @param planCode
*/
void delEquPlanDetailByPlanCode(String planCode);
}

@ -65,4 +65,16 @@ public interface EquPlanEquMapper {
* @return
*/
List<EquPlanEqu> selectEquPlanEquByPlanCode(String planCode);
/**
* code
* @param planCode
*/
void deleteEquPlanEquByPlanCode(String planCode);
/**
*
* @param planCode
*/
void delEquPlanEquByPlanCode(String planCode);
}

@ -83,4 +83,10 @@ public interface EquPlanMapper {
* @return
*/
EquPlan selectEquPlanByPlanCode(String planCode);
/**
*
* @param planCode
*/
void delEquPlanByPlanCode(String planCode);
}

@ -65,4 +65,16 @@ public interface EquPlanPersonMapper {
* @return
*/
List<EquPlanPerson> selectEquPlanPersonByPlanCode(String planCode);
/**
* code
* @param planCode
*/
void deleteEquPlanPersonByPlanCode(String planCode);
/**
*
* @param planCode
*/
void delEquPlanPersonByPlanCode(String planCode);
}

@ -65,4 +65,16 @@ public interface EquPlanStandardMapper {
* @return
*/
List<EquPlanStandard> selectEquPlanStandardByPlanCode(String planCode);
/**
* code
* @param planCode
*/
void deleteEquPlanStandardByPlanCode(String planCode);
/**
*
* @param planCode
*/
void delEquPlanStandardByPlanCode(String planCode);
}

@ -46,7 +46,7 @@ public interface IEquPlanService {
* @param equPlan
* @return
*/
public int updateEquPlan(EquPlan equPlan);
public AjaxResult updateEquPlan(EquPlan equPlan);
/**
*
@ -54,7 +54,7 @@ public interface IEquPlanService {
* @param planIds
* @return
*/
public int deleteEquPlanByPlanIds(String[] planIds);
public AjaxResult deleteEquPlanByPlanIds(String[] planIds);
/**
*

@ -121,113 +121,11 @@ public class EquPlanServiceImpl implements IEquPlanService {
equPlan.setUpdateBy(SecurityContextHolder.getUserName());
equPlan.setUpdateTime(DateUtils.getNowDate());
// 处理计划-巡检人员信息
List<SysUser> personList = equPlan.getPersonList();
for (SysUser user : personList) {
EquPlanPerson equPlanPerson = new EquPlanPerson();
equPlanPerson.setId(IdUtils.fastSimpleUUID());
equPlanPerson.setUserId(user.getUserId());
equPlanPerson.setPlanCode(equPlan.getPlanCode());
equPlanPerson.setFactoryCode(factory);
equPlanPerson.setCreateBy(SecurityContextHolder.getUserName());
equPlanPerson.setCreateTime(DateUtils.getNowDate());
equPlanPerson.setUpdateBy(SecurityContextHolder.getUserName());
equPlanPerson.setUpdateTime(DateUtils.getNowDate());
equPlanPersonMapper.insertEquPlanPerson(equPlanPerson);
System.out.println("人员信息插入数据库成功");
}
// 处理计划1-n设备信息
List<EquPlanEqu> equipmentItemList = equPlan.getEquipmentItem();
// 计划-设备流水号
int equipmentCodeTemp = 0;
for (EquPlanEqu equipment : equipmentItemList) {
equipment.setId(IdUtils.fastSimpleUUID());
equipment.setPlanCode(equPlan.getPlanCode());
equipment.setCode("E" + equPlan.getPlanCode() + String.format("%02d", ++equipmentCodeTemp));
equipment.setParentCode(equPlan.getPlanCode());
equipment.setFactoryCode(factory);
equipment.setCreateBy(SecurityContextHolder.getUserName());
equipment.setCreateTime(DateUtils.getNowDate());
equipment.setUpdateBy(SecurityContextHolder.getUserName());
equipment.setUpdateTime(DateUtils.getNowDate());
// 处理检查项信息
List<EquCheckItem> equCheckItemList = equipment.getEquCheckItemList();
// 计划检查项流水号
int itemCodeTemp = 0;
for (EquCheckItem item : equCheckItemList) {
EquPlanDetail planDetail = new EquPlanDetail();
BeanUtils.copyProperties(item, planDetail);
planDetail.setId(IdUtils.fastSimpleUUID());
planDetail.setPlanCode(equPlan.getPlanCode());
planDetail.setCode("C" + equPlan.getPlanCode() + String.format("%02d", ++itemCodeTemp));
planDetail.setParentCode(equipment.getCode());
planDetail.setCreateBy(SecurityContextHolder.getUserName());
planDetail.setCreateTime(DateUtils.getNowDate());
planDetail.setUpdateBy(SecurityContextHolder.getUserName());
planDetail.setUpdateTime(DateUtils.getNowDate());
// 处理标准
List<EquCheckItemDetail> equCheckItemDetailList = item.getEquCheckItemDetailList();
// 检查项详情流水号
int detailCodeTemp = 0;
// 判断是否插入检查项
boolean checkInsert = false;
for (EquCheckItemDetail detail : equCheckItemDetailList) {
if (detail.getShowFlag()) {
checkInsert = true;
EquPlanStandard planStandard = new EquPlanStandard();
BeanUtils.copyProperties(detail, planStandard);
planStandard.setId(IdUtils.fastSimpleUUID());
planStandard.setParentCode(planDetail.getCode());
planStandard.setPlanCode(equPlan.getPlanCode());
planStandard.setCode("D" + equPlan.getPlanCode() + String.format("%02d", ++detailCodeTemp));
planStandard.setCreateBy(SecurityContextHolder.getUserName());
planStandard.setCreateTime(DateUtils.getNowDate());
planStandard.setUpdateBy(SecurityContextHolder.getUserName());
planStandard.setUpdateTime(DateUtils.getNowDate());
// 详情插入数据库
equPlanStandardMapper.insertEquPlanStandard(planStandard);
System.out.println("检查项详情插入数据库成功");
}
}
// 检查项详情为空则不生成检查项信息-检查项插入数据库
if (checkInsert) {
equPlanDetailMapper.insertEquPlanDetail(planDetail);
System.out.println("检查项插入数据库成功");
}
}
// 设备插入数据库
equPlanEquMapper.insertEquPlanEqu(equipment);
System.out.println("设备信息插入数据库成功");
}
// 插入设备、人员、检查项、标准信息
insertCommonInfo(equPlan, factory);
// 主计划插入数据库
equPlanMapper.insertEquPlan(equPlan);
System.out.println("巡检主计划插入数据库成功");
return success();
}
@ -240,9 +138,28 @@ public class EquPlanServiceImpl implements IEquPlanService {
*/
@Override
@DS("#header.poolName")
public int updateEquPlan(EquPlan equPlan) {
equPlan.setUpdateTime(DateUtils.getNowDate());
return equPlanMapper.updateEquPlan(equPlan);
public AjaxResult updateEquPlan(EquPlan equPlan) {
// 更新巡检计划
equPlan.setPlanLoopStart(equPlan.getPlanTimeArray().get(0));
equPlan.setPlanLoopEnd(equPlan.getPlanTimeArray().get(1));
equPlanMapper.updateEquPlan(equPlan);
// 删除该计划下设备、人员、检查项、标准
equPlanPersonMapper.deleteEquPlanPersonByPlanCode(equPlan.getPlanCode());
equPlanDetailMapper.deleteEquPlanDetailByPlanCode(equPlan.getPlanCode());
equPlanEquMapper.deleteEquPlanEquByPlanCode(equPlan.getPlanCode());
equPlanStandardMapper.deleteEquPlanStandardByPlanCode(equPlan.getPlanCode());
//获取当前所选工厂
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String key = "#header.poolName";
String str = request.getHeader(key.substring(8));
int index = str.indexOf("_");
String factory = str.substring(index + 1);
// 插入设备、人员、检查项、标准信息
insertCommonInfo(equPlan, factory);
return success();
}
/**
@ -253,8 +170,17 @@ public class EquPlanServiceImpl implements IEquPlanService {
*/
@Override
@DS("#header.poolName")
public int deleteEquPlanByPlanIds(String[] planIds) {
return equPlanMapper.deleteEquPlanByPlanIds(planIds);
public AjaxResult deleteEquPlanByPlanIds(String[] planIds) {
// 逻辑删除信息
for (String id : planIds) {
EquPlan equPlan = equPlanMapper.selectEquPlanByPlanId(id);
equPlanMapper.delEquPlanByPlanCode(equPlan.getPlanCode());
equPlanPersonMapper.delEquPlanPersonByPlanCode(equPlan.getPlanCode());
equPlanDetailMapper.delEquPlanDetailByPlanCode(equPlan.getPlanCode());
equPlanEquMapper.delEquPlanEquByPlanCode(equPlan.getPlanCode());
equPlanStandardMapper.delEquPlanStandardByPlanCode(equPlan.getPlanCode());
}
return success();
}
/**
@ -266,7 +192,7 @@ public class EquPlanServiceImpl implements IEquPlanService {
@Override
@DS("#header.poolName")
public int deleteEquPlanByPlanId(String planId) {
return equPlanMapper.deleteEquPlanByPlanId(planId);
return 1;
}
/**
@ -332,6 +258,7 @@ public class EquPlanServiceImpl implements IEquPlanService {
/**
*
*
* @return
*/
@Override
@ -350,6 +277,7 @@ public class EquPlanServiceImpl implements IEquPlanService {
/**
*
*
* @param equPlan
* @return
*/
@ -404,4 +332,117 @@ public class EquPlanServiceImpl implements IEquPlanService {
return success(plan);
}
/**
*
*
* @param equPlan
* @param factory
*/
private void insertCommonInfo(EquPlan equPlan, String factory) {
// 处理计划-巡检人员信息
List<SysUser> personList = equPlan.getPersonList();
for (SysUser user : personList) {
EquPlanPerson equPlanPerson = new EquPlanPerson();
equPlanPerson.setId(IdUtils.fastSimpleUUID());
equPlanPerson.setUserId(user.getUserId());
equPlanPerson.setPlanCode(equPlan.getPlanCode());
equPlanPerson.setFactoryCode(factory);
equPlanPerson.setCreateBy(SecurityContextHolder.getUserName());
equPlanPerson.setCreateTime(DateUtils.getNowDate());
equPlanPerson.setUpdateBy(SecurityContextHolder.getUserName());
equPlanPerson.setUpdateTime(DateUtils.getNowDate());
equPlanPersonMapper.insertEquPlanPerson(equPlanPerson);
}
// 处理计划1-n设备信息
List<EquPlanEqu> equipmentItemList = equPlan.getEquipmentItem();
// 计划-设备流水号
int equipmentCodeTemp = 0;
for (EquPlanEqu equipment : equipmentItemList) {
equipment.setId(IdUtils.fastSimpleUUID());
equipment.setPlanCode(equPlan.getPlanCode());
equipment.setCode("E" + equPlan.getPlanCode() + String.format("%02d", ++equipmentCodeTemp));
equipment.setParentCode(equPlan.getPlanCode());
equipment.setFactoryCode(factory);
equipment.setCreateBy(SecurityContextHolder.getUserName());
equipment.setCreateTime(DateUtils.getNowDate());
equipment.setUpdateBy(SecurityContextHolder.getUserName());
equipment.setUpdateTime(DateUtils.getNowDate());
// 处理检查项信息
List<EquCheckItem> equCheckItemList = equipment.getEquCheckItemList();
if (equCheckItemList != null) {
// 计划检查项流水号
int itemCodeTemp = 0;
for (EquCheckItem item : equCheckItemList) {
if (item != null) {
EquPlanDetail planDetail = new EquPlanDetail();
BeanUtils.copyProperties(item, planDetail);
planDetail.setId(IdUtils.fastSimpleUUID());
planDetail.setPlanCode(equPlan.getPlanCode());
planDetail.setCode("C" + equPlan.getPlanCode() + String.format("%02d", ++itemCodeTemp));
planDetail.setParentCode(equipment.getCode());
planDetail.setCreateBy(SecurityContextHolder.getUserName());
planDetail.setCreateTime(DateUtils.getNowDate());
planDetail.setUpdateBy(SecurityContextHolder.getUserName());
planDetail.setUpdateTime(DateUtils.getNowDate());
// 处理标准
List<EquCheckItemDetail> equCheckItemDetailList = item.getEquCheckItemDetailList();
// 检查项详情流水号
int detailCodeTemp = 0;
// 判断是否插入检查项
boolean checkInsert = false;
for (EquCheckItemDetail detail : equCheckItemDetailList) {
if (detail.getShowFlag()) {
checkInsert = true;
EquPlanStandard planStandard = new EquPlanStandard();
BeanUtils.copyProperties(detail, planStandard);
planStandard.setId(IdUtils.fastSimpleUUID());
planStandard.setParentCode(planDetail.getCode());
planStandard.setPlanCode(equPlan.getPlanCode());
planStandard.setCode("D" + equPlan.getPlanCode() + String.format("%02d", ++detailCodeTemp));
planStandard.setCreateBy(SecurityContextHolder.getUserName());
planStandard.setCreateTime(DateUtils.getNowDate());
planStandard.setUpdateBy(SecurityContextHolder.getUserName());
planStandard.setUpdateTime(DateUtils.getNowDate());
// 详情插入数据库
equPlanStandardMapper.insertEquPlanStandard(planStandard);
}
}
// 检查项详情为空则不生成检查项信息-检查项插入数据库
if (checkInsert) {
equPlanDetailMapper.insertEquPlanDetail(planDetail);
}
}
}
// 设备插入数据库
equPlanEquMapper.insertEquPlanEqu(equipment);
}
}
}
}

@ -145,4 +145,12 @@
#{id}
</foreach>
</delete>
<delete id="deleteEquPlanDetailByPlanCode">
delete from equ_plan_detail where plan_code = #{planCode}
</delete>
<delete id="delEquPlanDetailByPlanCode">
update equ_plan_detail set del_flag = '1' where plan_code = #{planCode}
</delete>
</mapper>

@ -120,4 +120,12 @@
#{id}
</foreach>
</delete>
<delete id="deleteEquPlanEquByPlanCode">
delete from equ_plan_equ where plan_code = #{planCode}
</delete>
<delete id="delEquPlanEquByPlanCode">
update equ_plan_equ set del_flag = '1' where plan_code = #{planCode}
</delete>
</mapper>

@ -67,12 +67,13 @@
<if test="updateTimeStart != null "> and CONVERT(date,update_time) >= #{updateTimeStart}</if>
<if test="updateTimeEnd != null "> and #{updateTimeEnd} >= CONVERT(date,update_time)</if>
<if test="updateBy != null and updateBy != ''"> and update_by like concat('%', #{updateBy}, '%')</if>
and del_flag = '0'
</where>
</select>
<select id="selectEquPlanByPlanId" parameterType="String" resultMap="EquPlanResult">
<include refid="selectEquPlanVo"/>
where plan_id = #{planId}
where plan_id = #{planId} and del_flag = '0'
</select>
<select id="selectSerialNumber" resultType="java.lang.Integer">
@ -176,15 +177,12 @@
<if test="attr2 != null">attr2 = #{attr2},</if>
<if test="attr3 != null">attr3 = #{attr3},</if>
<if test="delFlag != null and delFlag != ''">del_flag = #{delFlag},</if>
<if test="createTimeStart != null "> and CONVERT(date,create_time) >= #{createTimeStart}</if>
<if test="createTimeEnd != null "> and #{createTimeEnd} >= CONVERT(date,create_time)</if>
<if test="createBy != null and createBy != ''"> and create_by like concat('%', #{createBy}, '%')</if>
<if test="updateTimeStart != null "> and CONVERT(date,update_time) >= #{updateTimeStart}</if>
<if test="updateTimeEnd != null "> and #{updateTimeEnd} >= CONVERT(date,update_time)</if>
<if test="updateBy != null and updateBy != ''"> and update_by like concat('%', #{updateBy}, '%')</if>
and del_flag = '0'
<if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where plan_id = #{planId}
where plan_id = #{planId} and del_flag = '0'
</update>
<delete id="deleteEquPlanByPlanId" parameterType="String">
@ -197,4 +195,8 @@
#{planId}
</foreach>
</delete>
<delete id="delEquPlanByPlanCode">
update equ_plan set del_flag = '1' where plan_code = #{planCode} and del_flag = '0'
</delete>
</mapper>

@ -110,4 +110,12 @@
#{id}
</foreach>
</delete>
<delete id="deleteEquPlanPersonByPlanCode">
delete from equ_plan_person where plan_code = #{planCode}
</delete>
<delete id="delEquPlanPersonByPlanCode">
update equ_plan_person set del_flag = '1' where plan_code = #{planCode}
</delete>
</mapper>

@ -140,4 +140,12 @@
#{id}
</foreach>
</delete>
<delete id="deleteEquPlanStandardByPlanCode">
delete from equ_plan_standard where plan_code = #{planCode}
</delete>
<delete id="delEquPlanStandardByPlanCode">
update equ_plan_standard set del_flag = '1' where plan_code = #{planCode}
</delete>
</mapper>
Loading…
Cancel
Save