Przeglądaj źródła

发函催告
审核文件/计划附件 上传
年度计划导入

buzhanyi 2 lat temu
rodzic
commit
22f3b424ea

+ 18 - 0
purchase-admin/src/main/java/com/ozs/web/controller/plan/PlanYearsController.java

@@ -103,6 +103,24 @@ public class PlanYearsController extends BaseController {
         return planYearsService.reviewReturn(yearsStandardVo);
     }
 
+    @ApiOperation(value = "发函催告")
+    @PostMapping("/sendLetter")
+    public AjaxResult sendLetter(@RequestBody PlanYearsStandardVo yearsStandardVo) {
+        return planYearsService.sendLetter(yearsStandardVo);
+    }
+
+    @ApiOperation(value = "上传计划关联文件后保存文件信息")
+    @PostMapping("/upLoadPlanFile")
+    public AjaxResult upLoadPlanFile(@RequestBody PlanYearsStandardVo yearsStandardVo) {
+        return planYearsService.upLoadPlanFile(yearsStandardVo);
+    }
+    //
+    //@ApiOperation(value = "下载计划关联文件")
+    //@PostMapping("/downLoadPlanFile")
+    //public AjaxResult downLoadPlanFile(@RequestBody PlanYearsStandardVo yearsStandardVo) {
+    //    return planYearsService.downLoadPlanFile(yearsStandardVo);
+    //}
+
     @ApiOperation(value = "导入年度计划数据")
     @PostMapping("/importData")
     public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception {

+ 3 - 4
purchase-common/src/main/java/com/ozs/common/enums/SysFileRefEnum.java

@@ -11,13 +11,12 @@ public enum SysFileRefEnum {
 
     PLAN_YEAR(1, "年度计划附件"),
     PLAN_TEMPORARY(2, "临时、季度计划附件"),
+    PLAN_YEAR_EXAMINE(3, "年度计划审核文件"),
 
     ;
 
-    private  Integer type;
-    private  String info;
-
-
+    private Integer type;
+    private String info;
 
 
 }

+ 5 - 0
purchase-system/pom.xml

@@ -22,6 +22,11 @@
             <groupId>com.ozs</groupId>
             <artifactId>purchase-common</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.hibernate.javax.persistence</groupId>
+            <artifactId>hibernate-jpa-2.0-api</artifactId>
+            <version>1.0.1.Final</version>
+        </dependency>
 
     </dependencies>
 

+ 11 - 5
purchase-system/src/main/java/com/ozs/plan/doman/PlanYears.java

@@ -5,7 +5,10 @@ import com.fasterxml.jackson.annotation.JsonFormat;
 import com.ozs.common.annotation.Excel;
 import com.ozs.common.core.domain.BaseEntity;
 import lombok.Data;
+import nonapi.io.github.classgraph.json.Id;
 
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
 import javax.validation.constraints.NotNull;
 import java.math.BigDecimal;
 import java.util.Date;
@@ -19,6 +22,8 @@ public class PlanYears extends BaseEntity {
     /**
      * 主键编号
      */
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
     private Long planYearId;
     /**
      * 采购单位(登录账号的单位)
@@ -95,7 +100,7 @@ public class PlanYears extends BaseEntity {
      */
     @Excel(name = "项目属性")
     @NotNull(message = "项目属性不能为空")
-    private String projectAtt;
+    private String projectAttr;
     /**
      * 计划调整情况及理由--->如计划需要变更,在填写申请修改时需填写调整情况及理由,审核单位审核通过后显示
      */
@@ -114,13 +119,14 @@ public class PlanYears extends BaseEntity {
      */
     private String projectStatus;
     /**
-     * 退回原因--->审核不通过就是退回
+     * 发函状态(0:未发函或已处理,1:确认发函)
      */
-    private String refuseReason;
+    private String sendLetter;
     /**
-     * 项目附件
+     * 退回原因--->审核不通过就是退回
      */
-    private String projectFiles;
+    private String refuseReason;
+
     /**
      * 创建者
      */

+ 9 - 6
purchase-system/src/main/java/com/ozs/plan/doman/vo/requestVo/PlanYearsStandardVo.java

@@ -3,11 +3,13 @@ package com.ozs.plan.doman.vo.requestVo;
 
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.ozs.common.core.domain.BaseEntity;
+import com.ozs.system.domain.SysFileRef;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
 import java.math.BigDecimal;
 import java.util.Date;
+import java.util.List;
 
 /**
  * @author buzhanyi
@@ -94,7 +96,7 @@ public class PlanYearsStandardVo extends BaseEntity {
      * 项目属性--->应急应战项目、重大规划任务项目、规划任务项目或一般项目
      */
     @ApiModelProperty(value = "项目属性")
-    private String projectAtt;
+    private String projectAttr;
 
     /**
      * 项目状态--->包括计划待提交、计划待审核、计划已退回、计划已审核
@@ -112,11 +114,7 @@ public class PlanYearsStandardVo extends BaseEntity {
      */
     @ApiModelProperty(value = "备注")
     private String remarks;
-    /**
-     * 项目附件
-     */
-    @ApiModelProperty(value = "项目附件")
-    private String projectFiles;
+
     /**
      * 退回原因--->审核不通过就是退回
      */
@@ -132,4 +130,9 @@ public class PlanYearsStandardVo extends BaseEntity {
      * 更改者
      */
     private String updated;
+
+    /**
+     * 上传附件
+     */
+    List<SysFileRef> sysFileRefs;
 }

+ 7 - 4
purchase-system/src/main/java/com/ozs/plan/doman/vo/responseVo/PlanYearsResponseVo.java

@@ -97,13 +97,16 @@ public class PlanYearsResponseVo {
      */
     @Excel(name = "项目状态")
     private String projectStatus;
+
     /**
-     * 退回原因--->审核不通过就是退回
+     * 发函状态(0:未发函或已处理,1:确认发函)
      */
-    private String refuseReason;
+    private String sendLetter;
+
     /**
-     * 项目附件
+     * 退回原因--->审核不通过就是退回
      */
-    private String projectFiles;
+    private String refuseReason;
+
 
 }

+ 5 - 2
purchase-system/src/main/java/com/ozs/plan/mapper/PlanYearsMapper.java

@@ -1,6 +1,7 @@
 package com.ozs.plan.mapper;
 
 
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.ozs.plan.doman.PlanYears;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
@@ -13,7 +14,7 @@ import java.util.List;
  * @author bu
  */
 @Mapper
-public interface PlanYearsMapper {
+public interface PlanYearsMapper extends BaseMapper<PlanYears> {
 
     /**
      * 查询年度计划记录集合
@@ -36,7 +37,7 @@ public interface PlanYearsMapper {
      *
      * @param planYears 年度计划请求对象
      */
-    public int insertPlanYears(PlanYears planYears);
+    public Long insertPlanYears(PlanYears planYears);
 
     /**
      * 批量删除年度计划
@@ -83,4 +84,6 @@ public interface PlanYearsMapper {
     public int commit(Long planYearId);
 
     public int review(PlanYears ofYears);
+
+    int sendLetter(Long planYearId);
 }

+ 25 - 1
purchase-system/src/main/java/com/ozs/plan/service/PlanYearsService.java

@@ -104,8 +104,32 @@ public interface PlanYearsService {
     /**
      * 申请修改年度计划
      *
-     * @param yearsStandardVo 需要审核的年度计划
+     * @param yearsStandardVo 需要修改的年度计划
      * @return 结果
      */
     public AjaxResult appUpdate(PlanYearsStandardVo yearsStandardVo);
+
+    /**
+     * 发函催告
+     *
+     * @param yearsStandardVo 年度计划
+     * @return 结果
+     */
+    AjaxResult sendLetter(PlanYearsStandardVo yearsStandardVo);
+
+    /**
+     * 上传计划关联文件后保存文件信息
+     *
+     * @param yearsStandardVo 年度计划
+     * @return 结果
+     */
+    AjaxResult upLoadPlanFile(PlanYearsStandardVo yearsStandardVo);
+
+    /**
+     * 下载计划关联文件
+     *
+     * @param yearsStandardVo 年度计划
+     * @return 结果
+     */
+    AjaxResult downLoadPlanFile(PlanYearsStandardVo yearsStandardVo);
 }

+ 144 - 23
purchase-system/src/main/java/com/ozs/plan/service/impl/PlanYearsServiceImpl.java

@@ -1,10 +1,13 @@
 package com.ozs.plan.service.impl;
 
+import com.ozs.common.constant.UserConstants;
 import com.ozs.common.core.domain.AjaxResult;
+import com.ozs.common.core.domain.entity.SysDept;
 import com.ozs.common.core.domain.entity.SysDictData;
 import com.ozs.common.core.domain.model.LoginUser;
 import com.ozs.common.enums.ProjectStatus;
 import com.ozs.common.enums.ProjectTypes;
+import com.ozs.common.enums.SysFileRefEnum;
 import com.ozs.common.exception.ServiceException;
 import com.ozs.common.utils.StringUtils;
 import com.ozs.common.utils.bean.BeanUtils;
@@ -13,7 +16,10 @@ import com.ozs.plan.doman.vo.requestVo.PlanYearsStandardVo;
 import com.ozs.plan.doman.vo.responseVo.PlanYearsResponseVo;
 import com.ozs.plan.mapper.PlanYearsMapper;
 import com.ozs.plan.service.PlanYearsService;
+import com.ozs.system.domain.SysFileRef;
 import com.ozs.system.domain.vo.responseVo.SysDeptResponseVo;
+import com.ozs.system.mapper.SysDeptMapper;
+import com.ozs.system.mapper.SysFileRefMapper;
 import com.ozs.system.service.ISysDeptService;
 import com.ozs.system.service.ISysDictTypeService;
 import com.ozs.system.service.impl.SysUserServiceImpl;
@@ -29,6 +35,7 @@ import java.util.Date;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * @author buzhanyi
@@ -45,11 +52,17 @@ public class PlanYearsServiceImpl implements PlanYearsService {
     private ISysDictTypeService dictTypeService;
     @Autowired
     private ISysDeptService deptService;
+    @Autowired
+    SysFileRefMapper sysFileRefMapper;
+    @Autowired
+    private SysDeptMapper deptMapper;
 
     @Override
     public List<PlanYears> selectPlanYearsList(PlanYearsStandardVo vo) {
         PlanYears ofYears = new PlanYears();
         List<PlanYears> planYears = new ArrayList<>();
+        List<PlanYears> planYearsList = new ArrayList<>();
+
         try {
             BeanUtils.copyProperties(vo, ofYears);
             planYears = planYearsMapper.selectPlanYearsList(ofYears);
@@ -57,10 +70,11 @@ public class PlanYearsServiceImpl implements PlanYearsService {
                 SysDeptResponseVo sysDeptResponseVo = (SysDeptResponseVo) deptService.selectDeptById(planYear.getPurchaseDeptId()).get("sysDept");
                 planYear.setPurchaseDeptName(sysDeptResponseVo.getDeptName());
             }
+            planYearsList = changeTo(planYears);
         } catch (Exception e) {
             e.printStackTrace();
         }
-        return planYears;
+        return planYearsList;
     }
 
     @Override
@@ -94,8 +108,19 @@ public class PlanYearsServiceImpl implements PlanYearsService {
         //判断是否为超额计划
         ofYears.setIsExcess(isExcessOrNo(ofYears.getProjectType(), ofYears.getEvaluation()));
         ofYears.setProjectStatus(ProjectStatus.PLANWAITCOMMIT.getCode());
+        ofYears.setSendLetter("0");
         ofYears.setCreateTime(new Date());
-        planYearsMapper.insertPlanYears(ofYears);
+        Long insertId = planYearsMapper.insertPlanYears(ofYears);
+        List<SysFileRef> sysFileRefs = yearsStandardVo.getSysFileRefs();
+        for (SysFileRef ref : sysFileRefs) {
+            ref.setRedId(insertId);
+            ref.setType(SysFileRefEnum.PLAN_YEAR.getType());
+            ref.setCreated(ofYears.getCreated());
+            ref.setCreateTime(new Date());
+            ref.setUpdated(ofYears.getCreated());
+            ref.setUpdateTime(new Date());
+            sysFileRefMapper.insert(ref);
+        }
         return AjaxResult.success();
     }
 
@@ -118,8 +143,9 @@ public class PlanYearsServiceImpl implements PlanYearsService {
         if (byId == null) {
             return AjaxResult.error("数据查询失败");
         }
-        BeanUtils.copyProperties(byId, planYearsResponseVo);
-        return AjaxResult.success(planYearsResponseVo);
+        ArrayList<PlanYears> years = new ArrayList<>();
+        years.add(byId);
+        return AjaxResult.success(changeTo(years).get(0));
     }
 
     @Override
@@ -135,6 +161,7 @@ public class PlanYearsServiceImpl implements PlanYearsService {
         }
         ofYears.setIsExcess(isExcessOrNo(ofYears.getProjectType(), ofYears.getEvaluation()));
         ofYears.setUpdateTime(new Date());
+        ofYears.setSendLetter("0");
         planYearsMapper.updateById(ofYears);
         return AjaxResult.success();
     }
@@ -145,41 +172,49 @@ public class PlanYearsServiceImpl implements PlanYearsService {
             throw new ServiceException("导入年度计划数据不能为空!");
         }
         HashMap<String, HashMap<String, String>> planEnums = dictTypeService.getAboutEnums();
-        HashMap<String, String> projectTypesMap = planEnums.get("ProjectTypes");
-        HashMap<String, String> planPurchaseModesMap = planEnums.get("PlanPurchaseModes");
-        HashMap<String, String> projectAttributes = planEnums.get("ProjectAttributes");
+        HashMap<String, String> projectTypesMap = planEnums.get("projectTypes");
+        HashMap<String, String> planPurchaseModesMap = planEnums.get("planPurchaseModes");
+        HashMap<String, String> projectAttributes = planEnums.get("projectAttributes");
         HashMap<String, String> purchaseServices = planEnums.get("purchaseServices");
-        //deptService.se
+
         int successNum = 0;
         int failureNum = 0;
         StringBuilder successMsg = new StringBuilder();
         StringBuilder failureMsg = new StringBuilder();
+        //deptService
         for (PlanYears ofYear : planYears) {
             try {
                 //验证项目名称是否重复导入
                 List<PlanYears> plan = planYearsMapper.countProjectName(ofYear.getProjectName());
-
+                //将录入信息中的值更改为要保存的数据
                 if (plan.size() == 0) {
-                    //将录入信息中的值更改为要保存的数据
+                    //采购单位
+                    SysDept info = deptMapper.checkDeptNameOnlyOne(ofYear.getPurchaseDeptName());
+                    if (StringUtils.isNotNull(info)) {
+                        ofYear.setPurchaseDeptId(info.getDeptId());
+                    }
                     ofYear.setProjectType(projectTypesMap.get(ofYear.getProjectType()));
                     ofYear.setProjectStatus(ProjectStatus.PLANWAITCOMMIT.getCode());
                     ofYear.setPurchaseMode(planPurchaseModesMap.get(ofYear.getPurchaseMode()));
                     //项目属性是多选字段
-                    String[] split = ofYear.getProjectAtt().split(",");
                     StringBuilder builder = new StringBuilder();
-                    if (split.length > 1) {
+                    if (ofYear.getProjectAttr().contains(",")) {
+                        String[] split = ofYear.getProjectAttr().split(",");
                         for (String s : split) {
                             builder.append(projectAttributes.get(s) + ",");
                         }
+                    } else {
+                        builder.append(projectAttributes.get(ofYear.getProjectAttr()));
                     }
-                    ofYear.setProjectAtt(builder.toString());
+                    ofYear.setProjectAttr(builder.toString());
                     ofYear.setPurchaseServices(purchaseServices.get(ofYear.getPurchaseServices()));
+                    ofYear.setSendLetter("0");
+                    ofYear.setIsExcess(isExcessOrNo(ofYear.getProjectType(), ofYear.getEvaluation()));
                     ofYear.setCreated(String.valueOf(loginUser.getUserId()));
                     ofYear.setCreateTime(new Date());
-                    //采购单位
                     planYearsMapper.insertPlanYears(ofYear);
                     successNum++;
-                    successMsg.append("<br/>" + successNum + "、项目 " + ofYear.getProjectName() + " 导入成功");
+                    successMsg.append("*" + successNum + "、项目 " + ofYear.getProjectName() + " 导入成功!");
                     //} else if (isUpdateSupport) {
                     //    PlanYears years = plan.get(0);
                     //    BeanValidators.validateWithException(validator, ofYear);
@@ -190,17 +225,17 @@ public class PlanYearsServiceImpl implements PlanYearsService {
                     //    successMsg.append("<br/>" + successNum + "、项目 " + ofYear.getProjectName() + " 更新成功");
                 } else {
                     failureNum++;
-                    failureMsg.append("<br/>" + successNum + "、项目 " + ofYear.getProjectName() + " 已存在");
+                    failureMsg.append("*" + successNum + "、项目 " + ofYear.getProjectName() + " 已存在");
                 }
             } catch (Exception exc) {
                 failureNum++;
-                String msg = "<br/>" + successNum + "、项目 " + ofYear.getProjectName() + " 导入失败";
+                String msg = "*" + successNum + "、项目 " + ofYear.getProjectName() + " 导入失败";
                 failureMsg.append(msg + exc.getMessage());
                 log.error(msg, exc);
             }
         }
         if (failureNum > 0) {
-            failureMsg.insert(0, "导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
+            failureMsg.insert(0, "导入失败!共 " + failureNum + " 条数据格式不正确:");
             throw new ServiceException(failureMsg.toString());
         } else {
             successMsg.insert(0, "导入成功!共 " + successNum + " 条,数据如下:");
@@ -243,13 +278,10 @@ public class PlanYearsServiceImpl implements PlanYearsService {
     @Override
     public AjaxResult reviewTo(PlanYearsStandardVo vo) {
         PlanYears ofYears = new PlanYears();
+        BeanUtils.copyProperties(vo, ofYears);
         ofYears.setPlanYearId(vo.getPlanYearId());
         ofYears.setProjectStatus(ProjectStatus.PLANTOEXAMINE.getCode());
-        int review = planYearsMapper.review(ofYears);
-        if (review != 1) {
-            return AjaxResult.error("项目状态数据异常");
-        }
-        return AjaxResult.success();
+        return review(vo, ofYears);
     }
 
     @Override
@@ -257,6 +289,16 @@ public class PlanYearsServiceImpl implements PlanYearsService {
         PlanYears ofYears = new PlanYears();
         BeanUtils.copyProperties(vo, ofYears);
         ofYears.setProjectStatus(ProjectStatus.PLANTOBACK.getCode());
+        return review(vo, ofYears);
+    }
+
+    private AjaxResult review(PlanYearsStandardVo vo, PlanYears ofYears) {
+        List<SysFileRef> sysFileRefs = vo.getSysFileRefs();
+        for (SysFileRef ref : sysFileRefs) {
+            ref.setRedId(vo.getPlanYearId());
+            ref.setType(SysFileRefEnum.PLAN_YEAR_EXAMINE.getType());
+            sysFileRefMapper.insert(ref);
+        }
         int review = planYearsMapper.review(ofYears);
         if (review != 1) {
             return AjaxResult.error("项目状态数据异常");
@@ -277,6 +319,32 @@ public class PlanYearsServiceImpl implements PlanYearsService {
         return AjaxResult.success();
     }
 
+    @Override
+    public AjaxResult sendLetter(PlanYearsStandardVo yearsStandardVo) {
+        int review = planYearsMapper.sendLetter(yearsStandardVo.getPlanYearId());
+        if (review != 1) {
+            return AjaxResult.error("项目状态数据异常");
+        }
+        return AjaxResult.success();
+    }
+
+    @Override
+    public AjaxResult upLoadPlanFile(PlanYearsStandardVo yearsStandardVo) {
+        List<SysFileRef> sysFileRefs = yearsStandardVo.getSysFileRefs();
+        for (SysFileRef ref : sysFileRefs) {
+            ref.setRedId(yearsStandardVo.getPlanYearId());
+            ref.setType(SysFileRefEnum.PLAN_YEAR.getType());
+            sysFileRefMapper.insert(ref);
+        }
+        return AjaxResult.success();
+    }
+
+    @Override
+    public AjaxResult downLoadPlanFile(PlanYearsStandardVo yearsStandardVo) {
+
+        return AjaxResult.success();
+    }
+
     //判断是否为超额计划
     public String isExcessOrNo(String projectType, BigDecimal evaluation) {
         BigDecimal threshold = new BigDecimal(0);
@@ -302,4 +370,57 @@ public class PlanYearsServiceImpl implements PlanYearsService {
             return ("0");
         }
     }
+
+    //字段赋值对应的名称
+    public List<PlanYears> changeTo(List<PlanYears> planYears) {
+
+        HashMap<String, HashMap<String, String>> planEnums = dictTypeService.getAboutEnums();
+        HashMap<String, String> projectTypesMap = planEnums.get("projectTypes");
+        HashMap<String, String> planPurchaseModesMap = planEnums.get("planPurchaseModes");
+        HashMap<String, String> projectAttributes = planEnums.get("projectAttributes");
+        HashMap<String, String> purchaseServices = planEnums.get("purchaseServices");
+        List<PlanYears> list = new ArrayList<PlanYears>();
+        for (PlanYears planYear : planYears) {
+            for (Map.Entry<String, String> entry : projectTypesMap.entrySet()) {
+                if (planYear.getProjectType().equals(entry.getValue())) {
+                    planYear.setProjectType(entry.getKey());
+                    break;
+                }
+            }
+            for (Map.Entry<String, String> entry : planPurchaseModesMap.entrySet()) {
+                if (planYear.getPurchaseMode().equals(entry.getValue())) {
+                    planYear.setPurchaseMode(entry.getKey());
+                    break;
+                }
+            }
+            //项目属性是拼接的
+            if (planYear.getProjectAttr().length() > 2) {
+                String[] split = planYear.getProjectAttr().split(",");
+                for (String s : split) {
+                    for (Map.Entry<String, String> entry : projectAttributes.entrySet()) {
+                        if (s.equals(entry.getValue())) {
+                            planYear.setProjectAttr(entry.getKey());
+                            break;
+                        }
+                    }
+                }
+            } else {
+                for (Map.Entry<String, String> entry : projectAttributes.entrySet()) {
+                    if (planYear.getProjectAttr().equals(entry.getValue())) {
+                        planYear.setProjectAttr(entry.getKey());
+                        break;
+                    }
+                }
+            }
+            for (Map.Entry<String, String> entry : purchaseServices.entrySet()) {
+                if (planYear.getPurchaseServices().equals(entry.getValue())) {
+                    planYear.setPurchaseServices(entry.getKey());
+                    break;
+                }
+            }
+
+            list.add(planYear);
+        }
+        return list;
+    }
 }

+ 8 - 0
purchase-system/src/main/java/com/ozs/system/mapper/SysDeptMapper.java

@@ -77,6 +77,14 @@ public interface SysDeptMapper
      */
     public SysDept checkDeptNameUnique(@Param("deptName") String deptName, @Param("parentId") Long parentId);
 
+    /**
+     * 校验部门名称是否唯一
+     *
+     * @param deptName 部门名称
+     * @return 结果
+     */
+    public SysDept checkDeptNameOnlyOne(@Param("deptName") String deptName);
+
     /**
      * 新增部门信息
      *

+ 12 - 4
purchase-system/src/main/resources/mapper/plan/PlanYearsMapper.xml

@@ -17,10 +17,11 @@
 		<result property="plan_demand_sub_time" column="planDemandSubTime"/>
 		<result property="plan_purchase_finish_time" column="planPurchaseFinishTime"/>
 		<result property="plan_deliver_time" column="planDeliverTime"/>
-		<result property="project_attr" column="projectAtt"/>
+		<result property="project_attr" column="projectAttr"/>
 		<result property="adjust_reason" column="adjustReason"/>
 		<result property="remarks" column="remarks"/>
 		<result property="project_status" column="projectStatus"/>
+		<result property="send_letter" column="sendLetter"/>
 		<result property="created" column="created"/>
 		<result property="create_time" column="createTime"/>
 		<result property="updated" column="updated"/>
@@ -41,7 +42,7 @@
 			plan_demand_sub_time=#{planDemandSubTime},
 			plan_purchase_finish_time=#{planPurchaseFinishTime},
 			plan_deliver_time=#{planDeliverTime},
-			project_attr=#{projectAtt},
+			project_attr=#{projectAttr},
 			adjust_reason=#{adjustReason},
 			remarks=#{remarks},
 			updated=#{updated},
@@ -127,7 +128,8 @@
 	</select>
 
 	<!--	创建计划信息-->
-	<insert id="insertPlanYears" parameterType="com.ozs.plan.doman.PlanYears">
+	<insert id="insertPlanYears" parameterType="com.ozs.plan.doman.PlanYears" useGeneratedKeys="true"
+			keyProperty="planYearId">
 		insert into plan_years (purchase_dept_id, project_name, project_type, demand_overview, evaluation, is_excess,
 								purchase_services, purchase_mode, plan_demand_sub_time, plan_purchase_finish_time,
 								plan_deliver_time, project_attr, adjust_reason, remarks, project_status,
@@ -135,7 +137,7 @@
 		values (#{purchaseDeptId}, #{projectName}, #{projectType}, #{demandOverview}, #{evaluation}, #{isExcess},
 				#{purchaseServices}, #{purchaseMode}, #{planDemandSubTime}, #{planPurchaseFinishTime},
 				#{planDeliverTime},
-				#{projectAtt}, #{adjustReason}, #{remarks}, #{projectStatus}, #{created}, #{createTime}, 0)
+				#{projectAttr}, #{adjustReason}, #{remarks}, #{projectStatus}, #{created}, #{createTime}, 0)
 	</insert>
 
 	<!--	计划删除-->
@@ -167,5 +169,11 @@
 		where plan_year_id = #{planYearId}
 	</update>
 
+	<update id="sendLetter" parameterType="java.lang.Long">
+		update plan_years
+		set send_letter=1
+		where plan_year_id = #{planYearId}
+	</update>
+
 
 </mapper>

+ 13 - 3
purchase-system/src/main/resources/mapper/system/SysDeptMapper.xml

@@ -77,16 +77,26 @@
 
     <select id="selectChildrenDeptById" parameterType="Long" resultMap="SysDeptResult">
 		select * from sys_dept where find_in_set(#{deptId}, ancestors)
-	</select>
+    </select>
 
     <select id="selectNormalChildrenDeptById" parameterType="Long" resultType="int">
-		select count(*) from sys_dept where status = 0 and del_flag = '0' and find_in_set(#{deptId}, ancestors)
-	</select>
+        select count(*)
+        from sys_dept
+        where status = 0
+          and del_flag = '0'
+          and find_in_set(#{deptId}, ancestors)
+    </select>
 
     <select id="checkDeptNameUnique" resultMap="SysDeptResult">
         <include refid="selectDeptVo"/>
         where dept_name=#{deptName} and parent_id = #{parentId} and del_flag = '0' limit 1
     </select>
+    <select id="checkDeptNameOnlyOne" resultType="com.ozs.common.core.domain.entity.SysDept"
+            parameterType="java.lang.String">
+        select dept_id
+        from sys_dept
+        where dept_name = #{deptName}
+    </select>
 
     <insert id="insertDept" parameterType="SysDept">
         insert into sys_dept(