|
|
@ -4,11 +4,16 @@ import java.math.BigDecimal; |
|
|
import java.util.*; |
|
|
import java.util.*; |
|
|
import java.util.stream.Collectors; |
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.json.JSONUtil; |
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
import com.hxhq.business.domain.*; |
|
|
import com.hxhq.business.domain.*; |
|
|
import com.hxhq.business.dto.mjy.DetailDto; |
|
|
import com.hxhq.business.dto.mjy.DetailDto; |
|
|
import com.hxhq.business.dto.mjy.ListDto; |
|
|
import com.hxhq.business.dto.mjy.ListDto; |
|
|
|
|
|
import com.hxhq.business.dto.study.StudyFormFillCc; |
|
|
|
|
|
import com.hxhq.business.dto.study.StudyFormFillCz; |
|
|
|
|
|
import com.hxhq.business.dto.study.StudyFormFillResource; |
|
|
import com.hxhq.business.enums.archive.ArchiveLogTypeEnum; |
|
|
import com.hxhq.business.enums.archive.ArchiveLogTypeEnum; |
|
|
import com.hxhq.business.enums.study.StudyTypeEnum; |
|
|
import com.hxhq.business.enums.study.StudyTypeEnum; |
|
|
import com.hxhq.business.enums.zykgl.*; |
|
|
import com.hxhq.business.enums.zykgl.*; |
|
|
@ -16,12 +21,14 @@ import com.hxhq.business.form.mjy.*; |
|
|
import com.hxhq.business.service.*; |
|
|
import com.hxhq.business.service.*; |
|
|
import com.hxhq.business.utils.JctUtil; |
|
|
import com.hxhq.business.utils.JctUtil; |
|
|
import com.hxhq.business.utils.ObjectCompareUtil; |
|
|
import com.hxhq.business.utils.ObjectCompareUtil; |
|
|
|
|
|
import com.hxhq.business.utils.lang.MjyJcnrUtil; |
|
|
import com.hxhq.common.core.exception.ServiceException; |
|
|
import com.hxhq.common.core.exception.ServiceException; |
|
|
import com.hxhq.common.core.utils.DateUtils; |
|
|
import com.hxhq.common.core.utils.DateUtils; |
|
|
import com.hxhq.common.core.utils.StringUtils; |
|
|
import com.hxhq.common.core.utils.StringUtils; |
|
|
import com.hxhq.common.security.utils.SecurityUtils; |
|
|
import com.hxhq.common.security.utils.SecurityUtils; |
|
|
import com.hxhq.system.api.domain.SysUser; |
|
|
import com.hxhq.system.api.domain.SysUser; |
|
|
import com.hxhq.system.service.ISysUserService; |
|
|
import com.hxhq.system.service.ISysUserService; |
|
|
|
|
|
import org.apache.commons.lang3.math.NumberUtils; |
|
|
import org.slf4j.Logger; |
|
|
import org.slf4j.Logger; |
|
|
import org.slf4j.LoggerFactory; |
|
|
import org.slf4j.LoggerFactory; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
@ -54,6 +61,8 @@ public class MjyServiceImpl extends ServiceImpl implements IMjyS |
|
|
private IArchiveLogService archiveLogService; |
|
|
private IArchiveLogService archiveLogService; |
|
|
@Autowired |
|
|
@Autowired |
|
|
private INoticeService noticeService; |
|
|
private INoticeService noticeService; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private IStudyMjyService studyMjyService; |
|
|
|
|
|
|
|
|
//region 资源库管理 |
|
|
//region 资源库管理 |
|
|
|
|
|
|
|
|
@ -1205,6 +1214,127 @@ public class MjyServiceImpl extends ServiceImpl implements IMjyS |
|
|
mjyTzService.saveTz(mjyOld.getId(),null,null,qmr,qmr2,null,null,null,null,null,"取出",mjyOld.getKc(),mjyOld.getKcdw(),form.getRemark()); |
|
|
mjyTzService.saveTz(mjyOld.getId(),null,null,qmr,qmr2,null,null,null,null,null,"取出",mjyOld.getKc(),mjyOld.getKcdw(),form.getRemark()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 表单生成 |
|
|
|
|
|
* @param studyFormFill |
|
|
|
|
|
* @param template |
|
|
|
|
|
* @param remark |
|
|
|
|
|
*/ |
|
|
|
|
|
@Override |
|
|
|
|
|
public void genResource(StudyFormFill studyFormFill, Template template,String remark) { |
|
|
|
|
|
System.out.println(System.currentTimeMillis()); |
|
|
|
|
|
SysUser qmr = sysUserService.selectUserById(SecurityUtils.getUserId()); |
|
|
|
|
|
|
|
|
|
|
|
Long studyId = studyFormFill.getStudyId(); |
|
|
|
|
|
Long studyFormId = studyFormFill.getId(); |
|
|
|
|
|
// 生成/使用 |
|
|
|
|
|
String resource = studyFormFill.getResource(); |
|
|
|
|
|
Map<String, Mjy> mjyMap = new HashMap<>(); |
|
|
|
|
|
List<Mjy> mjyList = new ArrayList<>(); |
|
|
|
|
|
LinkedList<MjyJcgj> jcgjList = new LinkedList<>(); |
|
|
|
|
|
LinkedList<MjyTz> tzList = new LinkedList<>(); |
|
|
|
|
|
if(StringUtils.isNotEmpty(resource) && !StringUtils.equals("[]", resource)) { |
|
|
|
|
|
List<StudyFormFillResource> studyFormFillResourceList = JSONUtil.toList(resource, StudyFormFillResource.class); |
|
|
|
|
|
List<String> bhList = studyFormFillResourceList.stream().map(StudyFormFillResource::getBh).collect(Collectors.toList()); |
|
|
|
|
|
// 根据编号获取需要处置的列表 |
|
|
|
|
|
LambdaQueryWrapper<Mjy> queryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
|
queryWrapper.in(Mjy::getBh, bhList); |
|
|
|
|
|
mjyList = this.list(queryWrapper); |
|
|
|
|
|
for (Mjy mjy : mjyList) { |
|
|
|
|
|
mjyMap.put(mjy.getBh(), mjy); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (StudyFormFillResource studyFormFillResource : studyFormFillResourceList) { |
|
|
|
|
|
Mjy mjy = mjyMap.get(studyFormFillResource.getBh()); |
|
|
|
|
|
if(mjy == null) { |
|
|
|
|
|
mjy = new Mjy(); |
|
|
|
|
|
mjy.setStudyId(studyId); |
|
|
|
|
|
mjy.setBdId(studyFormId); |
|
|
|
|
|
mjy.setZjzt(ZjztEnum.wrk.getValue()); |
|
|
|
|
|
mjy.setJyzt(JyztEnum.wjy.getValue()); |
|
|
|
|
|
} |
|
|
|
|
|
mjy.setMc(studyFormFillResource.getMc()); |
|
|
|
|
|
mjy.setBh(studyFormFillResource.getBh()); |
|
|
|
|
|
mjy.setNd(String.valueOf(studyFormFillResource.getNdz())); |
|
|
|
|
|
mjy.setNddw(studyFormFillResource.getNddw()); |
|
|
|
|
|
mjy.setKc(String.valueOf(studyFormFillResource.getKc())); |
|
|
|
|
|
mjy.setKcdw(studyFormFillResource.getKcdw()); |
|
|
|
|
|
mjy.setSxrq(DateUtils.parseDate(studyFormFillResource.getSxrq())); |
|
|
|
|
|
if(mjy.getId() == null) { |
|
|
|
|
|
this.save(mjy); |
|
|
|
|
|
mjyList.add(mjy); |
|
|
|
|
|
mjyMap.put(mjy.getBh(), mjy); |
|
|
|
|
|
// 稽查轨迹 |
|
|
|
|
|
jcgjList.add(mjyJcgjService.getJcgj(mjy.getId(), JcgjlxEnum.lc.getValue(), "配制完成",JcmcysEnum.green.getValue(), null, null, qmr,remark)); |
|
|
|
|
|
// 台账 |
|
|
|
|
|
tzList.add(mjyTzService.getTz(mjy.getId(), null,null, null,null, null,null, null,null, qmr,"配制完成" ,mjy.getKc(),mjy.getKcdw(), remark)); |
|
|
|
|
|
} else { |
|
|
|
|
|
this.updateById(mjy); |
|
|
|
|
|
} |
|
|
|
|
|
// 使用 |
|
|
|
|
|
String syl = studyFormFillResource.getSyl(); |
|
|
|
|
|
if(StringUtils.isNotEmpty(syl) && NumberUtils.isParsable(syl)) { |
|
|
|
|
|
BigDecimal kc = new BigDecimal(mjy.getKc()); |
|
|
|
|
|
kc = kc.subtract(new BigDecimal(syl)); |
|
|
|
|
|
baseMapper.updateKc(mjy.getId(), kc.toString()); |
|
|
|
|
|
// 使用稽查轨迹 |
|
|
|
|
|
HashMap<String, String> formData = new LinkedHashMap<>(); |
|
|
|
|
|
formData.put("使用量", syl + studyFormFillResource.getSyldw()); |
|
|
|
|
|
// 稽查轨迹 |
|
|
|
|
|
jcgjList.add(mjyJcgjService.getJcgj(mjy.getId(), JcgjlxEnum.lc.getValue(), "使用",JcmcysEnum.green.getValue(), JctUtil.formatStr(formData), JctUtil.formatStr(MjyJcnrUtil.getMapEn(formData)), qmr,remark)); |
|
|
|
|
|
// 台账 |
|
|
|
|
|
tzList.add(mjyTzService.getTz(mjy.getId(), null,null, null,null, null,null, null,null, qmr,"使用" ,mjy.getKc(),mjy.getKcdw(), remark)); |
|
|
|
|
|
} |
|
|
|
|
|
mjyMap.put(mjy.getBh(), mjy); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 存储 |
|
|
|
|
|
String cclist = studyFormFill.getCclist(); |
|
|
|
|
|
if(StringUtils.isNotEmpty(cclist) && !StringUtils.equals("[]", cclist)) { |
|
|
|
|
|
List<StudyFormFillCc> studyFormFillCcList = JSONUtil.toList(cclist, StudyFormFillCc.class); |
|
|
|
|
|
for (StudyFormFillCc studyFormFillCc : studyFormFillCcList) { |
|
|
|
|
|
baseMapper.updateCc(studyFormFillCc.getList(), studyFormFillCc.getCctj(), studyFormFillCc.getCcwz()); |
|
|
|
|
|
for (String bh : studyFormFillCc.getList()) { |
|
|
|
|
|
Mjy mjy = mjyMap.get(bh); |
|
|
|
|
|
|
|
|
|
|
|
// 稽查轨迹 |
|
|
|
|
|
HashMap<String, String> formData = new HashMap<>(); |
|
|
|
|
|
formData.put("存储位置", studyFormFillCc.getCcwz()); |
|
|
|
|
|
formData.put("存储条件", studyFormFillCc.getCctj()); |
|
|
|
|
|
jcgjList.add(mjyJcgjService.getJcgj(mjy.getId(), JcgjlxEnum.lc.getValue(), "存储",JcmcysEnum.green.getValue(), JctUtil.formatStr(formData), JctUtil.formatStr(MjyJcnrUtil.getMapEn(formData)), qmr,remark)); |
|
|
|
|
|
// 台账 |
|
|
|
|
|
tzList.add(mjyTzService.getTz(mjy.getId(), null,null, null,null, null,null, null,null, qmr,"存储" ,mjy.getKc(),mjy.getKcdw(), remark)); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 处置,库存全变为0 |
|
|
|
|
|
String czlist = studyFormFill.getCzlist(); |
|
|
|
|
|
if(StringUtils.isNotEmpty(czlist) && !StringUtils.equals("[]", czlist)) { |
|
|
|
|
|
List<StudyFormFillCz> studyFormFillCzList = JSONUtil.toList(czlist, StudyFormFillCz.class); |
|
|
|
|
|
for (StudyFormFillCz studyFormFillCz : studyFormFillCzList) { |
|
|
|
|
|
for (String bh : studyFormFillCz.getList()) { |
|
|
|
|
|
Mjy mjy = mjyMap.get(bh); |
|
|
|
|
|
// 稽查轨迹 |
|
|
|
|
|
HashMap<String, String> formData = new HashMap<>(); |
|
|
|
|
|
formData.put("处置方式", studyFormFillCz.getCzfs()); |
|
|
|
|
|
formData.put("处置量", mjy.getKc() + mjy.getKcdw()); |
|
|
|
|
|
jcgjList.add(mjyJcgjService.getJcgj(mjy.getId(), JcgjlxEnum.lc.getValue(), "存储",JcmcysEnum.green.getValue(), JctUtil.formatStr(formData), JctUtil.formatStr(MjyJcnrUtil.getMapEn(formData)), qmr,remark)); |
|
|
|
|
|
|
|
|
|
|
|
// 台账 |
|
|
|
|
|
tzList.add(mjyTzService.getTz(mjy.getId(), null,null, null,null, null,null, null,null, qmr,"处置" ,mjy.getKc(),mjy.getKcdw(), remark)); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
baseMapper.updateKcBatch(studyFormFillCz.getList(), "0"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
mjyJcgjService.saveBatch(jcgjList); |
|
|
|
|
|
mjyTzService.saveBatch(tzList); |
|
|
|
|
|
studyMjyService.saveBatch(studyId, mjyList); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
//endregion |
|
|
//endregion |
|
|
|
|
|
|
|
|
//region 档案管理 |
|
|
//region 档案管理 |
|
|
|