| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 |
- package cn.com.goldenwater.dcproj.service.impl.ducha;
- import cn.com.goldenwater.core.service.AbstractCrudService;
- import cn.com.goldenwater.dcproj.dao.*;
- import cn.com.goldenwater.dcproj.dto.AllNodeDto;
- import cn.com.goldenwater.dcproj.dto.BisInspGroupDto;
- import cn.com.goldenwater.dcproj.dto.ObjIdDto;
- import cn.com.goldenwater.dcproj.model.*;
- import cn.com.goldenwater.dcproj.param.BisInspPlanParam;
- import cn.com.goldenwater.dcproj.service.BisInspPlanService;
- import cn.com.goldenwater.dcproj.service.OlBisInspOrgService;
- import org.apache.commons.collections.map.HashedMap;
- import org.apache.commons.lang3.StringUtils;
- import org.apache.commons.lang3.math.NumberUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import org.springframework.transaction.annotation.Transactional;
- import java.text.SimpleDateFormat;
- import java.time.LocalDateTime;
- import java.util.*;
- /**
- * @author lune
- * @date 2019-2-18
- */
- @Service
- @Transactional(rollbackFor = Exception.class)
- public class BisInspPlanServiceImpl extends AbstractCrudService<BisInspPlan, BisInspPlanParam> implements BisInspPlanService {
- @Autowired
- private BisInspPlanDao bisInspPlanDao;
- @Autowired
- private BisInspAllDao bisInspAllDao;
- @Autowired
- private BisInspGroupDao bisInspGroupDao;
- @Autowired
- private AttPersBaseDao attPersBaseDao;
- @Autowired
- private BisInspObjDao bisInspObjDao;
- @Autowired
- private SupervisionPlanDao supervisionPlanDao;
- @Autowired
- private OlBisInspOrgDao bisInspOrgDao;
- @Autowired
- private OlBisInspOrgService olBisInspOrgService;
- public BisInspPlanServiceImpl(BisInspPlanDao bisInspPlanDao) {
- super(bisInspPlanDao);
- this.bisInspPlanDao = bisInspPlanDao;
- }
- @Override
- public OrganizationAndBatchAndGroup addBisInspPlan(BisInspPlan bisInspPlan) {
- if (null == bisInspPlan) {
- return null;
- }
- BisInspAll bisInspAll = new BisInspAll();
- //根据父id查询最大的子id
- BisInspAll max = bisInspAllDao.getMaxOne(bisInspPlan.getGuid(), bisInspPlan.getOrgId());
- if (null != max) {
- Long upOne = NumberUtils.toLong(max.getId());
- String newId = String.format("%0" + max.getId().length() + "d", (upOne + 1));
- bisInspAll.setId(newId);
- } else {
- bisInspAll.setId(bisInspPlan.getGuid() + "001");
- }
- if (bisInspPlan.getPalnSttm() != null) {
- String year = new SimpleDateFormat("yyyy").format(bisInspPlan.getPalnSttm());
- String mnth = new SimpleDateFormat("MM").format(bisInspPlan.getPalnSttm());
- bisInspAll.setInspYear(year);
- bisInspAll.setInspMnth(mnth);
- } else {
- String year = new SimpleDateFormat("yyyy").format(LocalDateTime.now());
- String mnth = new SimpleDateFormat("MM").format(LocalDateTime.now());
- bisInspAll.setInspYear(year);
- bisInspAll.setInspMnth(mnth);
- }
- bisInspAll.setEntm(bisInspPlan.getPalnEntm());
- bisInspAll.setSttm(bisInspPlan.getPalnSttm());
- bisInspAll.setProvince(bisInspPlan.getProvince());
- bisInspAll.setOrgName(bisInspPlan.getOrgName());
- bisInspAll.setPid(bisInspPlan.getGuid());
- bisInspAll.setPnm(bisInspPlan.getPrsnTitle());
- bisInspAll.setChkType(bisInspPlan.getChkType());
- bisInspAll.setChkForm(bisInspPlan.getChkForm());
- bisInspAll.setYearTaskId(bisInspPlan.getYearTaskId());
- bisInspAll.setLeadDep(bisInspPlan.getLeadDep());
- bisInspAll.setIsPlan(bisInspPlan.getIsPlan());
- bisInspAll.setOrgId(bisInspPlan.getOrgId());
- bisInspAll.setQuantity(bisInspPlan.getQuantity());
- bisInspAll.setPlanDpId(bisInspPlan.getPlanDpId());
- bisInspAll.setNote(bisInspPlan.getNote());
- bisInspAllDao.insert(bisInspAll);
- OrganizationAndBatchAndGroup result = new OrganizationAndBatchAndGroup();
- result.setName(bisInspPlan.getPrsnTitle());
- result.setCode(bisInspAll.getId());
- result.setType("3");
- return result;
- }
- @Override
- public List<BisInspGroupDto> findListByPersId(String persId) {
- return bisInspPlanDao.findListByPersId(persId);
- }
- @Override
- public Map<String, Object> getDetail(String inspGroupId, String plnaId) {
- HashMap<String, Object> result = new HashMap<>();
- BisInspPlan bisInspPlan = bisInspPlanDao.get(plnaId);
- result.put("plan", bisInspPlan == null ? new BisInspPlan() : bisInspPlan);
- BisInspGroup bisInspGroup = bisInspGroupDao.get(inspGroupId);
- result.put("group", bisInspGroup == null ? new BisInspGroup() : bisInspGroup);
- List<AttPersBase> listByInspGroupId = attPersBaseDao.getListByInspGroupId(inspGroupId);
- result.put("persList", listByInspGroupId == null ? new ArrayList<>() : listByInspGroupId);
- List<BisInspObj> listByGroupIdAndPlanId = bisInspObjDao.findListByGroupIdAndPlanId(inspGroupId, plnaId);
- result.put("objList", listByGroupIdAndPlanId == null ? new ArrayList<>() : listByGroupIdAndPlanId);
- return result;
- }
- @Override
- public Map<String, Object> deletePlan(String id, String orgId) {
- String province = olBisInspOrgService.getProvince(orgId);
- List<BisInspAllRlation> bisInspAllRlationList = this.bisInspPlanDao.getAllRlation(id, province);//人员和组
- List<BisInspAllObj> bisInspAllObjList = this.bisInspPlanDao.getAllObj(id, province);//对象和组
- List<BisInspSelArea> bisInspSelAreaList = this.bisInspPlanDao.getAllArea(id, orgId, province);
- Map<String, Object> map = new HashedMap();
- if (bisInspAllRlationList.size() > 0) {
- map.put("code", 1001);
- map.put("message", "请先删除人员或对象");
- } else if (bisInspAllObjList.size() > 0) {
- map.put("code", 1001);
- map.put("message", "请先删除人员或对象");
- } else if (bisInspSelAreaList.size() > 0) {
- map.put("code", 1001);
- map.put("message", "请先删除人员或对象");
- } else {
- bisInspAllDao.delete(id);
- map.put("code", 1002);
- map.put("message", "删除成功");
- }
- return map;
- }
- @Override
- public List<AllNodeDto> addInspPlanBatch(BisInspPlan bisInspPlan) {
- List<AllNodeDto> list = new ArrayList<>();
- if (bisInspPlan != null) {
- String objType = bisInspPlan.getObjType();
- String orgId = bisInspPlan.getOrgId();
- String orgName = bisInspPlan.getOrgName();
- if (StringUtils.isEmpty(orgName)) {
- OlBisInspOrg bisInspOrg = bisInspOrgDao.get(orgId);
- orgName = bisInspOrg.getOrgNm();
- }
- String persId = bisInspPlan.getPersId();
- String name = bisInspPlan.getPrsnTitle();
- Date sttm = bisInspPlan.getPalnSttm();
- Date entm = bisInspPlan.getPalnEntm();
- String province = olBisInspOrgService.getProvince(bisInspPlan.getOrgId());
- if (StringUtils.isNotEmpty(objType) && StringUtils.isNotEmpty(orgId)) {
- int type = Integer.parseInt(objType);
- String typeOrg = "00" + type + orgId;
- BisInspAll bisInspAll = bisInspAllDao.get(typeOrg);
- if (bisInspAll == null) {
- BisInspAll batch = new BisInspAll();
- batch.setId(typeOrg);
- batch.setPnm(orgName);
- batch.setPid("00" + type);
- batch.setSttm(sttm);
- batch.setEntm(entm);
- batch.setProvince(province);
- bisInspAllDao.insert(batch);
- }
- String newGroupId = "";
- ObjIdDto objIdDto = supervisionPlanDao.getMaxGroupId(typeOrg, orgId, province);
- if (objIdDto.getId() != null) {//如果该批次下有组,则组id加1
- String rtId = objIdDto.getId().substring(objIdDto.getId().length() - 1, objIdDto.getId().length());
- int i = Integer.parseInt(rtId) + 1;
- newGroupId = String.valueOf(i);
- if ("10".equals(newGroupId)) {
- String sid = objIdDto.getId().substring(objIdDto.getId().length() - 2, objIdDto.getId().length() - 1);
- int j = Integer.parseInt(sid) + 1;
- String ss = String.valueOf(j);
- newGroupId = objIdDto.getId().substring(0, objIdDto.getId().length() - 2) + ss + "0";
- } else {
- newGroupId = objIdDto.getId().substring(0, objIdDto.getId().length() - 1) + newGroupId;
- }
- } else {//如果该批次下没有组,则组id后三位为001
- newGroupId = typeOrg + "001";
- }
- BisInspAll batch = new BisInspAll();
- batch.setId(newGroupId);
- batch.setPnm(name);
- batch.setPid(typeOrg);
- batch.setSttm(sttm);
- batch.setProvince(province);
- batch.setEntm(entm);
- bisInspAllDao.insert(batch);
- list = supervisionPlanDao.getNodeByPersid(persId, type + "", orgId, province);
- }
- }
- return list;
- }
- }
|