浏览代码

质量事故单

yuansh 2 年之前
父节点
当前提交
1a88661933
共有 16 个文件被更改,包括 695 次插入187 次删除
  1. 12 1
      jeecg-boot/jeecg-boot-module-activiti/src/main/java/org/jeecg/modules/activiti/web/ActBusinessController.java
  2. 67 21
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oa/controller/IncidentTicketController.java
  3. 2 0
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oa/entity/IncidentTicket.java
  4. 4 2
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oa/entity/SyCarry.java
  5. 3 0
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oa/mapper/CdScheduleMapper.java
  6. 16 0
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oa/mapper/xml/CdScheduleMapper.xml
  7. 1 1
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oa/mapper/xml/IncidentTicketChildrenMapper.xml
  8. 2 0
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oa/mapper/xml/IncidentTicketMapper.xml
  9. 2 1
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oa/service/IIncidentTicketService.java
  10. 502 154
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oa/service/impl/IncidentTicketServiceImpl.java
  11. 6 5
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oa/service/impl/SyCarryServiceImpl.java
  12. 2 1
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oa/service/impl/SyCottonYarnServiceImpl.java
  13. 3 0
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oa/vo/IncidentTicketPage.java
  14. 6 0
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oa/vo/SyCarryPage.java
  15. 42 0
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/SysAnnouncementController.java
  16. 25 1
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/SysUserController.java

+ 12 - 1
jeecg-boot/jeecg-boot-module-activiti/src/main/java/org/jeecg/modules/activiti/web/ActBusinessController.java

@@ -640,7 +640,13 @@ public class ActBusinessController {
     @RequestMapping(value = "/getQueryColumnList", method = RequestMethod.GET)
     public Result getQueryColumnList(String tableName){
         List<Map<String,Object>> list = tbTableInfoMapper.getQueryColumnList(tableName);
-
+//        if(tableName.equals("incident_ticket")){
+//            Map<String,Object> map2 = new HashMap<>();
+//            map2.put("db_field_txt","计划单号");
+//            map2.put("db_field_name","incident_ticket_code_temp");
+//            map2.put("field_show_type","text");
+//            list.add(map2);
+//        }
         for(Map<String,Object> o:list){
             List<Map<String,String>> list2 = new ArrayList<>();
             if(o.get("field_show_type") == null || o.get("dict_table") == null || o.get("dict_field") == null){
@@ -711,6 +717,11 @@ public class ActBusinessController {
                 if(StringUtils.isBlank(type) || StringUtils.isBlank(name) || (StringUtils.isBlank(val1) && StringUtils.isBlank(val2))){
                     continue;
                 }
+
+//                if(name.equals("incident_ticket_code_temp")){
+//                    sb2.append(" and cl.id in( select incident_ticket_id from incident_ticket_children where plan_number ").append(" = '").append(val1).append("' ) ");
+//                    continue;
+//                }
                 if (type.equals("text")){
                     sb2.append(" and cl.").append(name).append(" like '%").append(val1).append("%' ");
                 }

+ 67 - 21
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oa/controller/IncidentTicketController.java

@@ -99,16 +99,20 @@ public class IncidentTicketController {
 								   HttpServletRequest req) {
 		QueryWrapper<IncidentTicket> queryWrapper = QueryGenerator.initQueryWrapper(incidentTicket, req.getParameterMap());
 		queryWrapper.eq("1","1");
-		queryWrapper.last("and id in(select table_id from act_z_business where table_name='incident_ticket' and result = 2) order by create_time desc ");
+//		queryWrapper.last("and id in(select table_id from act_z_business where table_name='incident_ticket' and result = 2) " +
+//				"order by accident_number desc ");
+
+		queryWrapper.last("and id in(select table_id from act_z_business where table_name='incident_ticket' and result = 2) " +
+				"order by date_format(create_time,'%Y-%m-%d') desc ,substring_index(accident_number, '-', -1) + 0 desc ");
 
 		Page<IncidentTicket> page = new Page<IncidentTicket>(pageNo, pageSize);
 		IPage<IncidentTicket> pageList = incidentTicketService.page(page, queryWrapper);
 
 		for (IncidentTicket o:pageList.getRecords()) {
 
-			List<IncidentTicketChildren> list = incidentTicketChildrenService.selectByMainId(o.getId());
-			String result = list.stream().map(IncidentTicketChildren::getPlanNumber).collect(Collectors.joining(","));
-			o.setJiHuaHao(result);
+//			List<IncidentTicketChildren> list = incidentTicketChildrenService.selectByMainId(o.getId());
+//			String result = list.stream().map(IncidentTicketChildren::getPlanNumber).collect(Collectors.joining(","));
+//			o.setJiHuaHao(result);
 
 			if(StringUtils.isNotBlank(o.getResponsibilityPerson1())){
 				LoginUser login = sysBaseAPI.getUserByName(o.getResponsibilityPerson1());
@@ -302,6 +306,10 @@ public class IncidentTicketController {
 			return Result.error("此单据状态下无法推送");
 		}
 
+		String accidentNumber = incidentTicket.getBusinessType();//业务类型
+		if(StringUtils.isBlank(accidentNumber)){
+			return Result.error("事故单号为空无法同步");
+		}
 		String businessType = incidentTicket.getBusinessType();//业务类型
 		if(StringUtils.isBlank(businessType)){
 			return Result.error("业务类型为空无法同步");
@@ -322,15 +330,24 @@ public class IncidentTicketController {
 			return Result.error("工厂为空责任单位");
 		}
 
+		boolean res = true;
 
 		List<IncidentTicketChildren> childrenList = incidentTicketChildrenService.selectByMainId(incidentTicket.getId());
 		StringBuffer sb = new StringBuffer();
 		for (IncidentTicketChildren o:childrenList){
 
+			String u8Invoice = o.getU8Invoice();//U8生成运费发票号
 			String exchangeRate = o.getExchangeRate();//子表汇率
 			String planNumber = o.getPlanNumber();//计划单号
 			String practicalSum = o.getPracticalSum();//实际事故金额
 			String zhanghaoId = o.getZhanghaoId();//账套号
+			String accidentType = o.getAccidentType();//事故类型 应补(负数) 扣款正数 不涉及金额(0)
+			if(StringUtils.isNotBlank(u8Invoice)){
+				continue;
+			}
+			if(StringUtils.isBlank(planNumber)){
+				return Result.error("计划单号为空");
+			}
 			if(StringUtils.isBlank(planNumber)){
 				return Result.error("计划单号为空");
 			}
@@ -340,31 +357,59 @@ public class IncidentTicketController {
 			if(StringUtils.isBlank(practicalSum)){
 				return Result.error("实际事故金额为空");
 			}
-			if(StringUtils.isBlank(practicalSum)){
-				return Result.error("实际事故金额为空");
-			}
 			if(StringUtils.isBlank(zhanghaoId)){
 				return Result.error("账套号为空");
 			}
-
-			Map<String,Object> cCode = incidentTicketService.propellingThree(incidentTicket,o);
+			if(StringUtils.isBlank(accidentType)){
+				return Result.error("事故类型为空");
+			}
+			res = false;
+			Map<String,Object> cCode = new HashMap<>();
+			if(zhanghaoId.equals("101")){
+				cCode = incidentTicketService.propellingOne(incidentTicket,o);
+			}else if(zhanghaoId.equals("102")){
+				cCode = incidentTicketService.propellingTwo(incidentTicket,o);
+			}else if(zhanghaoId.equals("103")){
+				cCode = incidentTicketService.propellingThree(incidentTicket,o);
+			}else{
+				sb.append("账套号无法识别:").append(zhanghaoId).append(";");
+			}
 			if(cCode.get("res").toString().equals("false")){
-				sb.append(cCode.get("msg").toString()).append("<br/>");
+				sb.append(cCode.get("msg").toString()).append(";");
+			}else if(cCode.get("res").toString().equals("noneTrue")){
+
 			}else{
 				o.setU8Invoice(cCode.get("cCode").toString());
 				incidentTicketChildrenService.updateById(o);
 			}
+
 		}
 
-//		LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-		incidentTicket.setState("4");
-//		incidentTicket.setUpdateBy(sysUser.getUsername());
-//		incidentTicket.setUpdateTime(new Date());
-//		incidentTicketService.updateById(incidentTicket);
+		if(res){
+			return Result.ok("该单据已推送");
+		}else{
 
-		return Result.ok(sb.toString());
-//		return incidentTicketService.propelling(incidentTicket);
+			if(StringUtils.isNotBlank(sb.toString())){
+				return Result.error(sb.toString());
+			}
 
+			boolean fnl = true;
+			List<IncidentTicketChildren> childrenList2 = incidentTicketChildrenService.selectByMainId(incidentTicket.getId());
+			for (IncidentTicketChildren o:childrenList2){
+				String accidentType = o.getAccidentType();//事故类型 应补(负数) 扣款 正数 不涉及金额(0)
+				String U8Invoice = o.getU8Invoice();//账套号
+				if(StringUtils.isBlank(U8Invoice) && !accidentType.equals("不涉及金额")){
+					fnl = false;
+					break;
+				}
+			}
+			if(fnl){
+				incidentTicket.setState("4");
+				incidentTicketService.updateById(incidentTicket);
+			}
+			return Result.ok("同步成功");
+
+		}
 
 	}
 
@@ -390,11 +435,12 @@ public class IncidentTicketController {
 		//完结操作可跳过推送,直接完结
 		if(incidentTicket.getState().equals("3") || incidentTicket.getState().equals("4")){//1未处理 2已通知 3通知已反馈 4已推送 5已完结
 			incidentTicket.setState("5");
-			LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-			incidentTicket.setUpdateBy(sysUser.getUsername());
-			incidentTicket.setUpdateTime(new Date());
+			incidentTicket.setStateText("已完结");
+//			LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+//			incidentTicket.setUpdateBy(sysUser.getUsername());
+//			incidentTicket.setUpdateTime(new Date());
 //			incidentTicketService.save(incidentTicket);
-			incidentTicketMapper.updateById(incidentTicket);
+			incidentTicketService.updateById(incidentTicket);
 			return Result.ok("已完结");
 		}else{
 			return Result.error("此单据状态下无法完结");

+ 2 - 0
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oa/entity/IncidentTicket.java

@@ -220,6 +220,8 @@ public class IncidentTicket implements Serializable {
 	@Excel(name = "1未处理 2已通知 3通知已反馈 4已推送 5已完结", width = 15)
     @ApiModelProperty(value = "1未处理 2已通知 3通知已反馈 4已推送 5已完结")
     private String state;
+	//未处理、已完结
+    private String stateText;
 
 	@TableField(exist = false)
 	private String jiHuaHao;//计划号(子表中数据,以逗号分割显示)

+ 4 - 2
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oa/entity/SyCarry.java

@@ -73,7 +73,9 @@ public class SyCarry implements Serializable {
     @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
 	private Date cwjlTime;
 	/**总计*/
-	@Excel(name = "总计", width = 15)
 	private Double totalNum;
-
+	/**备注2*/
+	private String remarks;//备注2
+	/**总计(大写)*/
+	private String totalText;//总计(大写)
 }

+ 3 - 0
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oa/mapper/CdScheduleMapper.java

@@ -30,4 +30,7 @@ public interface CdScheduleMapper extends BaseMapper<CdSchedule> {
     * @return int
     */
     int getLastMonth(@Param("cdSchedule")CdSchedule cdSchedule);
+
+    List<CdSchedule> getListByUser(@Param("userName")String userName);
+    int updateInfoNum(@Param("userName")String userName);
 }

+ 16 - 0
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oa/mapper/xml/CdScheduleMapper.xml

@@ -31,4 +31,20 @@
             AND create_by=#{cdSchedule.createBy}
         </if>
     </select>
+
+    <select id="getListByUser" resultType="org.jeecg.modules.oa.entity.CdSchedule">
+        SELECT
+           *
+        FROM
+            cd_schedule
+        WHERE del_flag = 0 and info_num > 0
+        and create_by = #{userName} and date_format(now(), '%Y%m%d') BETWEEN start_time and end_time
+    </select>
+
+    <update id="updateInfoNum">
+        update cd_schedule set info_num = 0
+        WHERE del_flag = 0 and info_num > 0
+        and create_by = #{userName} and date_format(now(), '%Y%m%d') BETWEEN start_time and end_time
+    </update>
+
 </mapper>

+ 1 - 1
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oa/mapper/xml/IncidentTicketChildrenMapper.xml

@@ -12,5 +12,5 @@
 		SELECT * 
 		FROM  incident_ticket_children
 		WHERE
-			 incident_ticket_id = #{mainId} 	</select>
+			 incident_ticket_id = #{mainId} order by sort</select>
 </mapper>

+ 2 - 0
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oa/mapper/xml/IncidentTicketMapper.xml

@@ -24,6 +24,7 @@
 
     <insert id="insertPurBillVouch">
         INSERT INTO PurBillVouch(
+            cPBVMemo,
             cPBVBillType,
             pbvid,
             cPBVCode,
@@ -59,6 +60,7 @@
 
         )
         VALUES (
+                #{PurBillVouch.cPBVMemo},
                 #{PurBillVouch.cPBVBillType},
                 #{PurBillVouch.pbvid},
                 #{PurBillVouch.cPBVCode},

+ 2 - 1
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oa/service/IIncidentTicketService.java

@@ -43,6 +43,7 @@ public interface IIncidentTicketService extends IService<IncidentTicket> {
 
 	public Result<?> noticeUserReturn(String headId, String code, String title);
 
-	public Result<?> propelling(IncidentTicket incidentTicket);
+	public Map<String,Object> propellingOne(IncidentTicket incidentTicket, IncidentTicketChildren children);
+	public Map<String,Object> propellingTwo(IncidentTicket incidentTicket, IncidentTicketChildren children);
 	public Map<String,Object> propellingThree(IncidentTicket incidentTicket, IncidentTicketChildren children);
 }

+ 502 - 154
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oa/service/impl/IncidentTicketServiceImpl.java

@@ -83,17 +83,37 @@ public class IncidentTicketServiceImpl extends ServiceImpl<IncidentTicketMapper,
 		System.out.println(cCode);
 	}
 
-	@DS("master3")
+	@DS("master1")
 	@Override
 	@Transactional
-	public Map<String,Object> propellingThree(IncidentTicket incidentTicket,IncidentTicketChildren children) {
+	public Map<String,Object> propellingOne(IncidentTicket incidentTicket,IncidentTicketChildren children) {
 		Map<String,Object> resMap = new HashMap<>();
 		resMap.put("res","false");
+
+		Map<String,Object> map = new HashMap<>();
+		String accidentType = children.getAccidentType();//事故类型 应补(负数) 扣款 正数 不涉及金额(0)
+		String accidentNumber = incidentTicket.getAccidentNumber();//质量事故单号
+		map.put("cPBVMemo", accidentNumber);//质量事故单号
+		if(accidentType.equals("不涉及金额")){
+			resMap.put("res","noneTrue");
+			return resMap;
+		}else if(accidentType.equals("扣款")){
+			map.put("bNegative", 1);//负发票标志 0蓝字 1红字
+
+		}else if(accidentType.equals("应补")){
+			map.put("bNegative", 0);//负发票标志 0蓝字 1红字
+
+		}else{
+			resMap.put("msg","事故类型有误:"+accidentType);
+			return resMap;
+		}
+
+
 		LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
 		String businessType = incidentTicket.getBusinessType();//业务类型
 		String moneyType = incidentTicket.getMoneyType();//币种
 		String accidentData = incidentTicket.getAccidentData();//日期
-		String factory = incidentTicket.getFactory();//工厂
+//		String factory = incidentTicket.getFactory();//工厂
 		String responsibilityCompany = incidentTicket.getResponsibilityCompany();//责任单位
 
 		String exchangeRate = children.getExchangeRate();//子表汇率
@@ -101,92 +121,86 @@ public class IncidentTicketServiceImpl extends ServiceImpl<IncidentTicketMapper,
 		String practicalSum = children.getPracticalSum();//实际事故金额
 		String zhanghaoId = children.getZhanghaoId();//账套
 
-		Map<String,Object> factoryMap = incidentTicketMapper.getVendor(factory);
+//		Map<String,Object> factoryMap = incidentTicketMapper.getVendor(factory);
 		Map<String,Object> responsibilityCompanyMap = incidentTicketMapper.getVendor(responsibilityCompany);
 
-		if(factoryMap == null){
-			resMap.put("msg",zhanghaoId+"账套不存在工厂 "+factory);
-			return resMap;
-		}
+//		if(factoryMap == null){
+//			resMap.put("msg",zhanghaoId+"账套不存在工厂 "+factory);
+//			return resMap;
+//		}
 		if(responsibilityCompanyMap == null){
 			resMap.put("msg",zhanghaoId+"账套不存在责任单位 "+responsibilityCompany);
 			return resMap;
 		}
 
-		Map<String,Object> map = new HashMap<>();
+
 		//推送正文
 		/**
 		 * 主表
 		 */
 		map.put("cPBVBillType","03");//发票类型 03
-		String cCode = "test";
-//		String cCode=this.addOne(incidentTicketMapper.getMaxCode("cPBVCode","PurBillVouch","cpbvcode"));
-//		incidentTicketMapper.updateVoucherHistoryCNumber(this.maxNumber(cCode),"2502");
 
-		map.put("cPBVCode",cCode);//采购发票号  生成
-		if(StringUtils.isNotBlank(businessType) && businessType.equals("委外加工")){
+		map.put("iVTid", 131586);//单据模版号
+		if(businessType.equals("委外加工")){
 			map.put("cPTCode","02");//采购类型编码 01普通采购 02委外加工
-		}else{
+			map.put("cBusType", "委外加工");//业务类型 普通采购/委外加工
+			map.put("cSource", "委外");//单据来源 采购、委外
+		}else if(businessType.equals("普通采购")){
 			map.put("cPTCode","01");//采购类型编码 01普通采购 02委外加工
+			map.put("cBusType", "普通采购");//业务类型 普通采购/委外加工
+			map.put("cSource", "采购");//单据来源 采购、委外
+		}else{
+			resMap.put("msg","业务类型有误 :"+businessType);
+			return resMap;
 		}
+
 		map.put("dPBVDate", DateUtils.getDate("yyyy-MM-dd"));//开票日期 当前日期
-		String cVenCode = factoryMap.get("cVenCode").toString();
+		String cVenCode = responsibilityCompanyMap.get("cVenCode").toString();
 		map.put("cVenCode", cVenCode);//供应商编码 对接质量事故单责任单位(U8显示简称即可)
 		String cUnitCode = responsibilityCompanyMap.get("cVenCode").toString();
 		map.put("cUnitCode", cUnitCode);//代垫单位编码 供应商
 		map.put("cexch_name", moneyType);//人民币、美元
-//		map.put("cExchRate", exchangeRate);//汇率 子表汇率
-		map.put("cExchRate", 12);//汇率 子表汇率
-		map.put("iPBVTaxRate", 0.0);//税率(101默认为0,102/103默认为13,可取U8该字段设置的默认值)
-		if(StringUtils.isNotBlank(businessType)){
-			map.put("cBusType", businessType);//业务类型 普通采购/委外加工
-		}else{
-			map.put("cBusType", "普通采购");//业务类型 普通采购/委外加工
-		}
+		map.put("cExchRate", exchangeRate);//汇率 子表汇率
+		map.put("iPBVTaxRate", 0);//税率(101默认为0,102/103默认为13,可取U8该字段设置的默认值)
 
 		map.put("cPBVMaker", sysUser.getRealname());//创建人 推送人姓名
-		map.put("bNegative", 0);//负发票标志 0
+
 		map.put("bOriginal", 0);//采购期初标志 0
 		map.put("bFirst", 0);//应付期初标志 0
 		map.put("iNetLock", 0);//现无用 0
 		map.put("cDefine2", planNumber);//计划单号 计划单号
 		map.put("dVouDate", accidentData);//单据日期 日期
-		map.put("iVTid", 8167);//单据模版号 8167
+
 //		map.put("ufts", DateUtils.getTimestamp());//时间戳
-//		map.put("cSource", businessType);//单据来源 采购、委外
-		map.put("cSource", "采购");//单据来源 采购、委外
-		map.put("cDefine12", factory);//江苏康弘纺织品有限公司
+
+		map.put("cDefine12", responsibilityCompany);//江苏康弘纺织品有限公司
 		map.put("cDefine13", responsibilityCompany);//江苏康弘纺织品有限公司
 		map.put("iDiscountTaxType",0);//扣税类别(0应税外加,1应税内含) 0
 		map.put("bCredit",0);//是否为立账依据0
 		String cVenAccount = "";
 		String cVenBank = "";
-		if(factoryMap.get("cVenAccount") != null){
-			cVenAccount = factoryMap.get("cVenAccount").toString();
+		if(responsibilityCompanyMap.get("cVenAccount") != null){
+			cVenAccount = responsibilityCompanyMap.get("cVenAccount").toString();
 		}
-		if(factoryMap.get("cVenBank") != null){
-			cVenBank = factoryMap.get("cVenBank").toString();
+		if(responsibilityCompanyMap.get("cVenBank") != null){
+			cVenBank = responsibilityCompanyMap.get("cVenBank").toString();
 		}
 		map.put("cVenAccount",cVenAccount);//供方银行账号
 		map.put("cVenBank",cVenBank);//供方银行名称
 		map.put("iPrintCount",0);//打印次数 0
 		String cVenContactCode = "";
 		String cVenPerson = "";
-		if(factoryMap.get("cVenContactCode") != null){
-			cVenContactCode = factoryMap.get("cVenContactCode").toString();
+		if(responsibilityCompanyMap.get("cVenContactCode") != null){
+			cVenContactCode = responsibilityCompanyMap.get("cVenContactCode").toString();
 		}
-		if(factoryMap.get("cVenPerson") != null){
-			cVenPerson = factoryMap.get("cVenPerson").toString();
+		if(responsibilityCompanyMap.get("cVenPerson") != null){
+			cVenPerson = responsibilityCompanyMap.get("cVenPerson").toString();
 		}
 		map.put("cContactCode",cVenContactCode);//供方联系人编码
 		map.put("cVenPerson",cVenPerson);//供方联系人
 		map.put("IsWfControlled",0);//是否工作流控制 0
-		StringBuffer sb = new StringBuffer();
-		sb.append("||puzl|");
-		sb.append(cCode);
-		map.put("csysbarcode",sb.toString());//单据条码 ||puzl|0000001185
-		map.put("cmaketime",DateUtils.now());//制单时间
 
+		map.put("cmaketime",DateUtils.now());//制单时间
 
 		/**
 		 * 子表
@@ -194,154 +208,488 @@ public class IncidentTicketServiceImpl extends ServiceImpl<IncidentTicketMapper,
 		Map<String,Object> map2 = new HashMap<>();
 
 
-
 		map2.put("cInvCode","N3000002424");//存货编码
 		map2.put("bExBill",1);//是否为费用 1
 //		map2.put("iPBVQuantity","1");//数量
-		//税率(101默认为0,102/103默认为13,可取U8该字段设置的默认值)
-		if(StringUtils.isNotBlank(practicalSum)){
 
-		}else{
-			map2.put("iOriMoney",0);//原币金额 -- 原币无税金额=原币金额/(1+税率)
-		}
-
-		map2.put("iOriSum",practicalSum);//原币价税合计  --实际事故金额
-		map2.put("iOriTaxPrice",0);//原币税额 原币金额-原币无税金额
-		map2.put("iMoney",practicalSum);//本币金额 (本币无税金额) 本币金额/(1+税率)
-		map2.put("iSum",practicalSum);//本币价税合计 原币金额*汇率
-		map2.put("iTaxPrice",practicalSum);//本币税额 本币金额-本币无税金额
-		map2.put("iTaxRate",0);//税率(101默认为0,102/103默认为13,可取U8该字段设置的默认值)
-		map2.put("ivouchrowno",1);//行号
-		map2.put("cbsysbarcode",sb.toString()+"|1");//行条码 ||puzl|0000001185|1
-		map2.put("bgift",0);//是否赠品 0
-
-//		int chId = incidentTicketMapper.getMaxCode2();
-//		map.put("pbvid",chId+1);//主表主键
-//		incidentTicketMapper.insertPurBillVouch(map);
-//
-//		int chIds = incidentTicketMapper.getMaxCode3();
-//		map2.put("pbvid",chId+1);//主表主键
-//		map2.put("id",chIds+1);//主键
-//		incidentTicketMapper.insertPurBillVouchs(map2);
+		try {
 
+			//税率(101默认为0,102/103默认为13,可取U8该字段设置的默认值)
+			BigDecimal sl = new BigDecimal("1");//税率
+			BigDecimal hl = new BigDecimal(exchangeRate);//汇率
+			//原币金额(无税) -- 原币无税金额=原币金额/(1+税率)
+			BigDecimal iOriMoney = new BigDecimal(practicalSum).divide(sl,BigDecimal.ROUND_HALF_UP).setScale(2,BigDecimal.ROUND_HALF_UP);
+			//原币税额 原币金额-原币无税金额
+			BigDecimal iOriTaxPrice = new BigDecimal(practicalSum).subtract(iOriMoney);
+			//本币价税合计 原币金额*汇率
+			BigDecimal iSum = new BigDecimal(practicalSum).multiply(hl);
+			//本币金额 (本币无税金额) 本币金额/(1+税率)
+			BigDecimal iMoney = iSum.divide(sl,BigDecimal.ROUND_HALF_UP).setScale(2,BigDecimal.ROUND_HALF_UP);
+			//本币税额 本币金额-本币无税金额
+			BigDecimal iTaxPrice = iSum.subtract(iMoney);
+
+			if(accidentType.equals("不涉及金额")){
+				map2.put("iOriMoney",0);//原币金额(无税) -- 原币无税金额=原币金额/(1+税率)
+				map2.put("iOriSum",0);//原币价税合计  --实际事故金额
+				map2.put("iOriSum",0);//原币价税合计  --实际事故金额
+				map2.put("iOriTaxPrice",0);//原币税额 原币金额-原币无税金额
+				map2.put("iSum",0);//本币价税合计 原币金额*汇率
+				map2.put("iMoney",0);//本币金额 (本币无税金额) 本币金额/(1+税率)
+				map2.put("iTaxPrice",0);//本币税额 本币金额-本币无税金额
+			}else if(accidentType.equals("扣款")){
+				map2.put("iOriMoney","-"+iOriMoney);//原币金额(无税) -- 原币无税金额=原币金额/(1+税率)
+				map2.put("iOriSum","-"+practicalSum);//原币价税合计  --实际事故金额
+				map2.put("iOriTaxPrice","-"+iOriTaxPrice);//原币税额 原币金额-原币无税金额
+				map2.put("iOriTaxPrice",0);//原币税额 原币金额-原币无税金额
+				map2.put("iSum","-"+iSum);//本币价税合计 原币金额*汇率
+				map2.put("iMoney","-"+iMoney);//本币金额 (本币无税金额) 本币金额/(1+税率)
+				map2.put("iTaxPrice",0);//本币税额 本币金额-本币无税金额
+
+			}else if(accidentType.equals("应补")){
+				map2.put("iOriMoney",iOriMoney);//原币金额(无税) -- 原币无税金额=原币金额/(1+税率)
+				map2.put("iOriSum",practicalSum);//原币价税合计  --实际事故金额
+				map2.put("iOriTaxPrice",0);//原币税额 原币金额-原币无税金额
+				map2.put("iSum",iSum);//本币价税合计 原币金额*汇率
+				map2.put("iMoney",iMoney);//本币金额 (本币无税金额) 本币金额/(1+税率)
+				map2.put("iTaxPrice",0);//本币税额 本币金额-本币无税金额
+			}else{
+				resMap.put("msg","事故类型有误:"+accidentType);
+				return resMap;
+			}
+
+			map2.put("iTaxRate",0);//税率(101默认为0,102/103默认为13,可取U8该字段设置的默认值)
+			map2.put("ivouchrowno",1);//行号
+
+			map2.put("bgift",0);//是否赠品 0
+
+			String cCode=this.addOne(incidentTicketMapper.getMaxCode("cPBVCode","PurBillVouch","cpbvcode"));
+			incidentTicketMapper.updateVoucherHistoryCNumber(this.maxNumber(cCode),"2502");
+
+			map.put("cPBVCode",cCode);//采购发票号  生成
+			resMap.put("cCode",cCode);
+			StringBuffer sb = new StringBuffer();
+			sb.append("||puzl|");
+			sb.append(cCode);
+			map.put("csysbarcode",sb.toString());//单据条码 ||puzl|0000001185
+			map2.put("cbsysbarcode",sb.toString()+"|1");//行条码 ||puzl|0000001185|1
+
+			int chId = incidentTicketMapper.getMaxCode2();
+			map.put("pbvid",chId+1);//主表主键
+			incidentTicketMapper.insertPurBillVouch(map);
+
+			int chIds = incidentTicketMapper.getMaxCode3();
+			map2.put("pbvid",chId+1);//主表主键
+			map2.put("id",chIds+1);//主键
+			incidentTicketMapper.insertPurBillVouchs(map2);
+
+		}catch (Exception e){
+			System.out.println(e.getMessage());
+			resMap.put("msg","同步数据有误,请联系管理员");
+			return resMap;
+		}
+
+		resMap.put("res","true");
 		return resMap;
 	}
 
-	@DS("master3")
+	@DS("master2")
 	@Override
 	@Transactional
-	public Result<?> propelling(IncidentTicket incidentTicket){
+	public Map<String,Object> propellingTwo(IncidentTicket incidentTicket,IncidentTicketChildren children) {
+		Map<String,Object> resMap = new HashMap<>();
+		resMap.put("res","false");
+		Map<String,Object> map = new HashMap<>();
 
-		if(!incidentTicket.getState().equals("3")){//1未处理 2已通知 3通知已反馈 4已推送 5已完结
-			return Result.error("此单据状态下无法推送");
+		String accidentType = children.getAccidentType();//事故类型 应补(负数) 扣款 正数 不涉及金额(0)
+		String accidentNumber = incidentTicket.getAccidentNumber();//质量事故单号
+		map.put("cPBVMemo", accidentNumber);//质量事故单号
+		if(accidentType.equals("不涉及金额")){
+			resMap.put("res","noneTrue");
+			return resMap;
+		}else if(accidentType.equals("扣款")){
+			map.put("bNegative", 1);//负发票标志 0蓝字 1红字
+		}else if(accidentType.equals("应补")){
+			map.put("bNegative", 0);//负发票标志 0蓝字 1红字
+		}else{
+			resMap.put("msg","事故类型有误:"+accidentType);
+			return resMap;
 		}
-		LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-
 
+		LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
 		String businessType = incidentTicket.getBusinessType();//业务类型
 		String moneyType = incidentTicket.getMoneyType();//币种
 		String accidentData = incidentTicket.getAccidentData();//日期
-		String factory = incidentTicket.getFactory();//工厂
+//		String factory = incidentTicket.getFactory();//工厂
 		String responsibilityCompany = incidentTicket.getResponsibilityCompany();//责任单位
-		List<IncidentTicketChildren> childrenList = incidentTicketChildrenMapper.selectByMainId(incidentTicket.getId());
 
-		for (IncidentTicketChildren children:childrenList){
+		String exchangeRate = children.getExchangeRate();//子表汇率
+		String planNumber = children.getPlanNumber();//计划单号
+		String practicalSum = children.getPracticalSum();//实际事故金额
+		String zhanghaoId = children.getZhanghaoId();//账套
 
-			String exchangeRate = children.getExchangeRate();//子表汇率
-			String planNumber = children.getPlanNumber();//计划单号
-			String practicalSum = children.getPracticalSum();//实际事故金额
+//		Map<String,Object> factoryMap = incidentTicketMapper.getVendor(factory);
+		Map<String,Object> responsibilityCompanyMap = incidentTicketMapper.getVendor(responsibilityCompany);
 
-			Map<String,Object> map = new HashMap<>();
-			//推送正文
-			/**
-			 * 主表
-			 */
-			map.put("cPBVBillType","03");//发票类型 03
+		if(responsibilityCompanyMap == null){
+			resMap.put("msg",zhanghaoId+"账套不存在责任单位 "+responsibilityCompany);
+			return resMap;
+		}
 
-			String cCode=this.addOne(incidentTicketMapper.getMaxCode("cPBVCode","PurBillVouch","cmaketime"));
-			incidentTicketMapper.updateVoucherHistoryCNumber(this.maxNumber(cCode),"2502");
 
-			map.put("PBVID","2"+cCode);//采购发票主表标识
-			map.put("cPBVCode",cCode);//采购发票号  生成
-			if(businessType.equals("普通采购")){
-				map.put("cPTCode","01");//采购类型编码 01普通采购 02委外加工
-			}else{
-				map.put("cPTCode","02");//采购类型编码 01普通采购 02委外加工
-			}
-			map.put("dPBVDate", DateUtils.getDate("yyyy-MM-dd"));//开票日期 当前日期
-			map.put("cVenCode", "0001");//供应商编码 对接质量事故单责任单位(U8显示简称即可)
-			map.put("cUnitCode", "0001");//代垫单位编码 供应商
-			map.put("cexch_name", moneyType);//人民币、美元
-//			map.put("cExchRate", exchangeRate);//汇率 子表汇率
-			map.put("cExchRate", 12.0);//汇率 子表汇率
-			map.put("iPBVTaxRate", 0);//税率(101默认为0,102/103默认为13,可取U8该字段设置的默认值)
-			if(StringUtils.isNotBlank(businessType)){
-				map.put("cBusType", businessType);//业务类型 普通采购/委外加工
+		//推送正文
+		/**
+		 * 主表
+		 */
+		map.put("cPBVBillType","03");//发票类型 03
+
+		map.put("iVTid", 131601);//单据模版号
+		if(businessType.equals("委外加工")){
+			map.put("cPTCode","02");//采购类型编码 01普通采购 02委外加工
+			map.put("cBusType", "委外加工");//业务类型 普通采购/委外加工
+			map.put("cSource", "委外");//单据来源 采购、委外
+		}else if(businessType.equals("普通采购")){
+			map.put("cPTCode","01");//采购类型编码 01普通采购 02委外加工
+			map.put("cBusType", "普通采购");//业务类型 普通采购/委外加工
+			map.put("cSource", "采购");//单据来源 采购、委外
+		}else{
+			resMap.put("msg","业务类型有误 :"+businessType);
+			return resMap;
+		}
+		map.put("dPBVDate", DateUtils.getDate("yyyy-MM-dd"));//开票日期 当前日期
+		String cVenCode = responsibilityCompanyMap.get("cVenCode").toString();
+		map.put("cVenCode", cVenCode);//供应商编码 对接质量事故单责任单位(U8显示简称即可)
+		String cUnitCode = responsibilityCompanyMap.get("cVenCode").toString();
+		map.put("cUnitCode", cUnitCode);//代垫单位编码 供应商
+		map.put("cexch_name", moneyType);//人民币、美元
+		map.put("cExchRate", exchangeRate);//汇率 子表汇率
+		map.put("iPBVTaxRate", 13);//税率(101默认为0,102/103默认为13,可取U8该字段设置的默认值)
+
+		map.put("cPBVMaker", sysUser.getRealname());//创建人 推送人姓名
+
+		map.put("bOriginal", 0);//采购期初标志 0
+		map.put("bFirst", 0);//应付期初标志 0
+		map.put("iNetLock", 0);//现无用 0
+		map.put("cDefine2", planNumber);//计划单号 计划单号
+		map.put("dVouDate", accidentData);//单据日期 日期
+
+//		map.put("ufts", DateUtils.getTimestamp());//时间戳
+
+		map.put("cDefine12", responsibilityCompany);//江苏康弘纺织品有限公司
+		map.put("cDefine13", responsibilityCompany);//江苏康弘纺织品有限公司
+		map.put("iDiscountTaxType",0);//扣税类别(0应税外加,1应税内含) 0
+		map.put("bCredit",0);//是否为立账依据0
+		String cVenAccount = "";
+		String cVenBank = "";
+		if(responsibilityCompanyMap.get("cVenAccount") != null){
+			cVenAccount = responsibilityCompanyMap.get("cVenAccount").toString();
+		}
+		if(responsibilityCompanyMap.get("cVenBank") != null){
+			cVenBank = responsibilityCompanyMap.get("cVenBank").toString();
+		}
+		map.put("cVenAccount",cVenAccount);//供方银行账号
+		map.put("cVenBank",cVenBank);//供方银行名称
+		map.put("iPrintCount",0);//打印次数 0
+		String cVenContactCode = "";
+		String cVenPerson = "";
+		if(responsibilityCompanyMap.get("cVenContactCode") != null){
+			cVenContactCode = responsibilityCompanyMap.get("cVenContactCode").toString();
+		}
+		if(responsibilityCompanyMap.get("cVenPerson") != null){
+			cVenPerson = responsibilityCompanyMap.get("cVenPerson").toString();
+		}
+		map.put("cContactCode",cVenContactCode);//供方联系人编码
+		map.put("cVenPerson",cVenPerson);//供方联系人
+		map.put("IsWfControlled",0);//是否工作流控制 0
+
+		map.put("cmaketime",DateUtils.now());//制单时间
+
+		/**
+		 * 子表
+		 */
+		Map<String,Object> map2 = new HashMap<>();
+
+
+		map2.put("cInvCode","N3000002424");//存货编码
+		map2.put("bExBill",1);//是否为费用 1
+//		map2.put("iPBVQuantity","1");//数量
+
+		try {
+
+			//税率(101默认为0,102/103默认为13,可取U8该字段设置的默认值)
+			BigDecimal sl = new BigDecimal("1.13");//税率
+			BigDecimal hl = new BigDecimal(exchangeRate);//汇率
+			//原币金额(无税) -- 原币无税金额=原币金额/(1+税率)
+			BigDecimal iOriMoney = new BigDecimal(practicalSum).divide(sl,BigDecimal.ROUND_HALF_UP).setScale(2,BigDecimal.ROUND_HALF_UP);
+			//原币税额 原币金额-原币无税金额
+			BigDecimal iOriTaxPrice = new BigDecimal(practicalSum).subtract(iOriMoney);
+			//本币价税合计 原币金额*汇率
+			BigDecimal iSum = new BigDecimal(practicalSum).multiply(hl);
+			//本币金额 (本币无税金额) 本币金额/(1+税率)
+			BigDecimal iMoney = iSum.divide(sl,BigDecimal.ROUND_HALF_UP).setScale(2,BigDecimal.ROUND_HALF_UP);
+			//本币税额 本币金额-本币无税金额
+			BigDecimal iTaxPrice = iSum.subtract(iMoney);
+
+			if(accidentType.equals("不涉及金额")){
+				map2.put("iOriMoney",0);//原币金额(无税) -- 原币无税金额=原币金额/(1+税率)
+				map2.put("iOriSum",0);//原币价税合计  --实际事故金额
+				map2.put("iOriSum",0);//原币价税合计  --实际事故金额
+				map2.put("iOriTaxPrice",0);//原币税额 原币金额-原币无税金额
+				map2.put("iSum",0);//本币价税合计 原币金额*汇率
+				map2.put("iMoney",0);//本币金额 (本币无税金额) 本币金额/(1+税率)
+				map2.put("iTaxPrice",0);//本币税额 本币金额-本币无税金额
+			}else if(accidentType.equals("扣款")){
+				map2.put("iOriMoney","-"+iOriMoney);//原币金额(无税) -- 原币无税金额=原币金额/(1+税率)
+				map2.put("iOriSum","-"+practicalSum);//原币价税合计  --实际事故金额
+				map2.put("iOriTaxPrice","-"+iOriTaxPrice);//原币税额 原币金额-原币无税金额
+				map2.put("iSum","-"+iSum);//本币价税合计 原币金额*汇率
+				map2.put("iMoney","-"+iMoney);//本币金额 (本币无税金额) 本币金额/(1+税率)
+				map2.put("iTaxPrice","-"+iTaxPrice);//本币税额 本币金额-本币无税金额
+
+			}else if(accidentType.equals("应补")){
+				map2.put("iOriMoney",iOriMoney);//原币金额(无税) -- 原币无税金额=原币金额/(1+税率)
+				map2.put("iOriSum",practicalSum);//原币价税合计  --实际事故金额
+				map2.put("iOriTaxPrice",iOriTaxPrice);//原币税额 原币金额-原币无税金额
+				map2.put("iSum",iSum);//本币价税合计 原币金额*汇率
+				map2.put("iMoney",iMoney);//本币金额 (本币无税金额) 本币金额/(1+税率)
+				map2.put("iTaxPrice",iTaxPrice);//本币税额 本币金额-本币无税金额
 			}else{
-				map.put("cBusType", "普通采购");//业务类型 普通采购/委外加工
+				resMap.put("msg","事故类型有误:"+accidentType);
+				return resMap;
 			}
 
-			map.put("cPBVMaker", sysUser.getRealname());//创建人 推送人姓名
-			map.put("bNegative", 0);//负发票标志 0
-			map.put("bOriginal", 0);//采购期初标志 0
-			map.put("bFirst", 0);//应付期初标志 0
-			map.put("iNetLock", 0);//现无用 0
-			map.put("cDefine2", planNumber);//计划单号 计划单号
-			map.put("dVouDate", accidentData);//单据日期 日期
-			map.put("iVTid", "8167");//单据模版号 8167
-//			map.put("ufts", DateUtils.getTimestamp());//时间戳
-			map.put("cSource", businessType);//单据来源 采购、委外
-			map.put("cDefine12", factory);//江苏康弘纺织品有限公司
-			map.put("cDefine13", responsibilityCompany);//江苏康弘纺织品有限公司
-			map.put("iDiscountTaxType",0);//扣税类别(0应税外加,1应税内含) 0
-			map.put("bCredit",0);//是否为立账依据0
-			map.put("cVenAccount","1112333333333");//供方银行账号
-			map.put("cVenBank","中国银行");//供方银行名称
-			map.put("iPrintCount",0);//打印次数 0
-			map.put("cContactCode","0001");//供方联系人编码
-			map.put("cVenPerson","同步");//供方联系人
-			map.put("IsWfControlled",0);//是否工作流控制 0
+			map2.put("iTaxRate",13);//税率(101默认为0,102/103默认为13,可取U8该字段设置的默认值)
+			map2.put("ivouchrowno",1);//行号
+
+			map2.put("bgift",0);//是否赠品 0
+
+			String cCode=this.addOne(incidentTicketMapper.getMaxCode("cPBVCode","PurBillVouch","cpbvcode"));
+			incidentTicketMapper.updateVoucherHistoryCNumber(this.maxNumber(cCode),"2502");
+
+			map.put("cPBVCode",cCode);//采购发票号  生成
+			resMap.put("cCode",cCode);
 			StringBuffer sb = new StringBuffer();
 			sb.append("||puzl|");
 			sb.append(cCode);
 			map.put("csysbarcode",sb.toString());//单据条码 ||puzl|0000001185
-			map.put("cmaketime",DateUtils.now());//制单时间
+			map2.put("cbsysbarcode",sb.toString()+"|1");//行条码 ||puzl|0000001185|1
+
+			int chId = incidentTicketMapper.getMaxCode2();
+			map.put("pbvid",chId+1);//主表主键
+			incidentTicketMapper.insertPurBillVouch(map);
+
+			int chIds = incidentTicketMapper.getMaxCode3();
+			map2.put("pbvid",chId+1);//主表主键
+			map2.put("id",chIds+1);//主键
+			incidentTicketMapper.insertPurBillVouchs(map2);
+
+		}catch (Exception e){
+			System.out.println(e.getMessage());
+			resMap.put("msg","同步数据有误,请联系管理员");
+			return resMap;
+		}
+
+		resMap.put("res","true");
+		return resMap;
+	}
+
+
+	@DS("master3")
+	@Override
+	@Transactional
+	public Map<String,Object> propellingThree(IncidentTicket incidentTicket,IncidentTicketChildren children) {
+		Map<String,Object> resMap = new HashMap<>();
+
+		//主表数据
+		Map<String,Object> map = new HashMap<>();
+		resMap.put("res","false");
+
+		String accidentType = children.getAccidentType();//事故类型 应补(负数) 扣款 正数 不涉及金额(0)
+		String accidentNumber = incidentTicket.getAccidentNumber();//质量事故单号
+		map.put("cPBVMemo", accidentNumber);//质量事故单号
+		if(accidentType.equals("不涉及金额")){
+			resMap.put("res","noneTrue");
+			return resMap;
+		}else if(accidentType.equals("扣款")){
+			map.put("bNegative", 1);//负发票标志 0蓝字 1红字
+
+		}else if(accidentType.equals("应补")){
+			map.put("bNegative", 0);//负发票标志 0蓝字 1红字
+
+		}else{
+			resMap.put("msg","事故类型有误:"+accidentType);
+			return resMap;
+		}
+		LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+		String businessType = incidentTicket.getBusinessType();//业务类型
+		String moneyType = incidentTicket.getMoneyType();//币种
+		String accidentData = incidentTicket.getAccidentData();//日期
+//		String factory = incidentTicket.getFactory();//工厂
+		String responsibilityCompany = incidentTicket.getResponsibilityCompany();//责任单位
+
+		String exchangeRate = children.getExchangeRate();//子表汇率
+		String planNumber = children.getPlanNumber();//计划单号
+		String practicalSum = children.getPracticalSum();//实际事故金额
+		String zhanghaoId = children.getZhanghaoId();//账套
+
+//		Map<String,Object> factoryMap = incidentTicketMapper.getVendor(factory);
+		Map<String,Object> responsibilityCompanyMap = incidentTicketMapper.getVendor(responsibilityCompany);
+
+		if(responsibilityCompanyMap == null){
+			resMap.put("msg",zhanghaoId+"账套不存在责任单位 "+responsibilityCompany);
+			return resMap;
+		}
+
+		//推送正文
+		/**
+		 * 主表
+		 */
+		map.put("cPBVBillType","03");//发票类型 03
+
+		map.put("iVTid", 8167);//单据模版号
+		if(businessType.equals("委外加工")){
+			map.put("cPTCode","02");//采购类型编码 01普通采购 02委外加工
+			map.put("cBusType", "委外加工");//业务类型 普通采购/委外加工
+			map.put("cSource", "委外");//单据来源 采购、委外
+		}else if(businessType.equals("普通采购")){
+			map.put("cPTCode","01");//采购类型编码 01普通采购 02委外加工
+			map.put("cBusType", "普通采购");//业务类型 普通采购/委外加工
+			map.put("cSource", "采购");//单据来源 采购、委外
+		}else{
+			resMap.put("msg","业务类型有误 :"+businessType);
+			return resMap;
+		}
+		map.put("dPBVDate", DateUtils.getDate("yyyy-MM-dd"));//开票日期 当前日期
+		String cVenCode = responsibilityCompanyMap.get("cVenCode").toString();
+		map.put("cVenCode", cVenCode);//供应商编码 对接质量事故单责任单位(U8显示简称即可)
+		String cUnitCode = responsibilityCompanyMap.get("cVenCode").toString();
+		map.put("cUnitCode", cUnitCode);//代垫单位编码 供应商
+		map.put("cexch_name", moneyType);//人民币、美元
+		map.put("cExchRate", exchangeRate);//汇率 子表汇率
+		map.put("iPBVTaxRate", 13);//税率(101默认为0,102/103默认为13,可取U8该字段设置的默认值)
 
+		map.put("cPBVMaker", sysUser.getRealname());//创建人 推送人姓名
+		map.put("bOriginal", 0);//采购期初标志 0
+		map.put("bFirst", 0);//应付期初标志 0
+		map.put("iNetLock", 0);//现无用 0
+		map.put("cDefine2", planNumber);//计划单号 计划单号
+		map.put("dVouDate", accidentData);//单据日期 日期
+//		map.put("ufts", DateUtils.getTimestamp());//时间戳
 
-			/**
-			 * 子表
-			 */
-			Map<String,Object> map2 = new HashMap<>();
+		map.put("cDefine12", responsibilityCompany);//江苏康弘纺织品有限公司
+		map.put("cDefine13", responsibilityCompany);//江苏康弘纺织品有限公司
+		map.put("iDiscountTaxType",0);//扣税类别(0应税外加,1应税内含) 0
+		map.put("bCredit",0);//是否为立账依据0
+		String cVenAccount = "";
+		String cVenBank = "";
+		if(responsibilityCompanyMap.get("cVenAccount") != null){
+			cVenAccount = responsibilityCompanyMap.get("cVenAccount").toString();
+		}
+		if(responsibilityCompanyMap.get("cVenBank") != null){
+			cVenBank = responsibilityCompanyMap.get("cVenBank").toString();
+		}
+		map.put("cVenAccount",cVenAccount);//供方银行账号
+		map.put("cVenBank",cVenBank);//供方银行名称
+		map.put("iPrintCount",0);//打印次数 0
+		String cVenContactCode = "";
+		String cVenPerson = "";
+		if(responsibilityCompanyMap.get("cVenContactCode") != null){
+			cVenContactCode = responsibilityCompanyMap.get("cVenContactCode").toString();
+		}
+		if(responsibilityCompanyMap.get("cVenPerson") != null){
+			cVenPerson = responsibilityCompanyMap.get("cVenPerson").toString();
+		}
+		map.put("cContactCode",cVenContactCode);//供方联系人编码
+		map.put("cVenPerson",cVenPerson);//供方联系人
+		map.put("IsWfControlled",0);//是否工作流控制 0
+
+		map.put("cmaketime",DateUtils.now());//制单时间
+
+		/**
+		 * 子表
+		 */
+		Map<String,Object> map2 = new HashMap<>();
+
+		map2.put("cInvCode","N3000002424");//存货编码
+		map2.put("bExBill",1);//是否为费用 1
+//		map2.put("iPBVQuantity","1");//数量
+
+		try {
 
-			map2.put("pbvid",map.get("PBVID"));//主表主键
-			map2.put("cInvCode","N3000002424");//存货编码
-			map2.put("bExBill",1);//是否为费用 1
-//			map2.put("iPBVQuantity","1");//数量
 			//税率(101默认为0,102/103默认为13,可取U8该字段设置的默认值)
-			map2.put("iOriMoney",practicalSum);//原币金额 -- 原币无税金额=原币金额/(1+税率)
-			map2.put("iOriSum",practicalSum);//原币价税合计  --实际事故金额
-			map2.put("iOriTaxPrice",0);//原币税额 原币金额-原币无税金额
-			map2.put("iMoney",practicalSum);//本币金额 (本币无税金额) 本币金额/(1+税率)
-			map2.put("iSum",practicalSum);//本币价税合计 原币金额*汇率
-			map2.put("iTaxPrice",practicalSum);//本币税额 本币金额-本币无税金额
-			map2.put("iTaxRate",0);//税率(101默认为0,102/103默认为13,可取U8该字段设置的默认值)
+			BigDecimal sl = new BigDecimal("1.13");//税率
+			BigDecimal hl = new BigDecimal(exchangeRate);//汇率
+			//原币金额(无税) -- 原币无税金额=原币金额/(1+税率)
+			BigDecimal iOriMoney = new BigDecimal(practicalSum).divide(sl,BigDecimal.ROUND_HALF_UP).setScale(2,BigDecimal.ROUND_HALF_UP);
+			//原币税额 原币金额-原币无税金额
+			BigDecimal iOriTaxPrice = new BigDecimal(practicalSum).subtract(iOriMoney);
+			//本币价税合计 原币金额*汇率
+			BigDecimal iSum = new BigDecimal(practicalSum).multiply(hl);
+			//本币金额 (本币无税金额) 本币金额/(1+税率)
+			BigDecimal iMoney = iSum.divide(sl,BigDecimal.ROUND_HALF_UP).setScale(2,BigDecimal.ROUND_HALF_UP);
+			//本币税额 本币金额-本币无税金额
+			BigDecimal iTaxPrice = iSum.subtract(iMoney);
+
+			if(accidentType.equals("不涉及金额")){
+				map2.put("iOriMoney",0);//原币金额(无税) -- 原币无税金额=原币金额/(1+税率)
+				map2.put("iOriSum",0);//原币价税合计  --实际事故金额
+				map2.put("iOriSum",0);//原币价税合计  --实际事故金额
+				map2.put("iOriTaxPrice",0);//原币税额 原币金额-原币无税金额
+				map2.put("iSum",0);//本币价税合计 原币金额*汇率
+				map2.put("iMoney",0);//本币金额 (本币无税金额) 本币金额/(1+税率)
+				map2.put("iTaxPrice",0);//本币税额 本币金额-本币无税金额
+			}else if(accidentType.equals("扣款")){
+				map2.put("iOriMoney","-"+iOriMoney);//原币金额(无税) -- 原币无税金额=原币金额/(1+税率)
+				map2.put("iOriSum","-"+practicalSum);//原币价税合计  --实际事故金额
+				map2.put("iOriTaxPrice","-"+iOriTaxPrice);//原币税额 原币金额-原币无税金额
+				map2.put("iSum","-"+iSum);//本币价税合计 原币金额*汇率
+				map2.put("iMoney","-"+iMoney);//本币金额 (本币无税金额) 本币金额/(1+税率)
+				map2.put("iTaxPrice","-"+iTaxPrice);//本币税额 本币金额-本币无税金额
+
+			}else if(accidentType.equals("应补")){
+				map2.put("iOriMoney",iOriMoney);//原币金额(无税) -- 原币无税金额=原币金额/(1+税率)
+				map2.put("iOriSum",practicalSum);//原币价税合计  --实际事故金额
+				map2.put("iOriTaxPrice",iOriTaxPrice);//原币税额 原币金额-原币无税金额
+				map2.put("iSum",iSum);//本币价税合计 原币金额*汇率
+				map2.put("iMoney",iMoney);//本币金额 (本币无税金额) 本币金额/(1+税率)
+				map2.put("iTaxPrice",iTaxPrice);//本币税额 本币金额-本币无税金额
+			}else{
+				resMap.put("msg","事故类型有误:"+accidentType);
+				return resMap;
+			}
+
+			map2.put("iTaxRate",13);//税率(101默认为0,102/103默认为13,可取U8该字段设置的默认值)
 			map2.put("ivouchrowno",1);//行号
-			map2.put("cbsysbarcode",sb.toString()+"|1");//行条码 ||puzl|0000001185|1
+
 			map2.put("bgift",0);//是否赠品 0
 
+			String cCode=this.addOne(incidentTicketMapper.getMaxCode("cPBVCode","PurBillVouch","cpbvcode"));
+			incidentTicketMapper.updateVoucherHistoryCNumber(this.maxNumber(cCode),"2502");
+
+			map.put("cPBVCode",cCode);//采购发票号  生成
+			resMap.put("cCode",cCode);
+			StringBuffer sb = new StringBuffer();
+			sb.append("||puzl|");
+			sb.append(cCode);
+			map.put("csysbarcode",sb.toString());//单据条码 ||puzl|0000001185
+			map2.put("cbsysbarcode",sb.toString()+"|1");//行条码 ||puzl|0000001185|1
+
+			int chId = incidentTicketMapper.getMaxCode2();
+			map.put("pbvid",chId+1);//主表主键
 			incidentTicketMapper.insertPurBillVouch(map);
+
+			int chIds = incidentTicketMapper.getMaxCode3();
+			map2.put("pbvid",chId+1);//主表主键
+			map2.put("id",chIds+1);//主键
 			incidentTicketMapper.insertPurBillVouchs(map2);
 
-			children.setU8Invoice(cCode);
-			incidentTicketChildrenMapper.updateById(children);
+		}catch (Exception e){
+			System.out.println(e.getMessage());
+			resMap.put("msg","同步数据有误,请联系管理员");
+			return resMap;
 		}
 
-
-		incidentTicket.setState("4");
-		incidentTicket.setUpdateBy(sysUser.getUsername());
-		incidentTicket.setUpdateTime(new Date());
-		incidentTicketMapper.updateById(incidentTicket);
-		return Result.ok("已推送");
+		resMap.put("res","true");
+		return resMap;
 	}
 
 	@Override
@@ -362,7 +710,7 @@ public class IncidentTicketServiceImpl extends ServiceImpl<IncidentTicketMapper,
 
 		for(String o:idList){
 
-			sysBaseAPI.sendSysAnnouncement(sysUser,sysUser.getUsername(),o,"质量事故单",code+"  "+title, CommonConstant.MSG_CATEGORY_2,taskParam);
+			sysBaseAPI.sendSysAnnouncement(sysUser,sysUser.getUsername(),o,"质量事故单 "+code,code+"  "+title, CommonConstant.MSG_CATEGORY_2,taskParam);
 			IncidentTicketMsg incidentTicketMsg = new IncidentTicketMsg();
 			LoginUser loginUser = sysBaseAPI.getUserByName(o);
 			incidentTicketMsg.setPkIncidentTicket(headId);
@@ -422,13 +770,13 @@ public class IncidentTicketServiceImpl extends ServiceImpl<IncidentTicketMapper,
 //			}
 		}
 
-		if(!isAuth){
-			return Result.error("您无权操作此事故单");
-		}
+//		if(!isAuth){
+//			return Result.error("您无权操作此事故单");
+//		}
 
 		HashMap<String,Object> taskParam = new HashMap<>();
 
-		sysBaseAPI.sendSysAnnouncement(sysUser,sysUser.getUsername(),"T0008","质量事故单",code+"  "+title+" 财务对单人已处理完毕;", CommonConstant.MSG_CATEGORY_2,taskParam);
+		sysBaseAPI.sendSysAnnouncement(sysUser,sysUser.getUsername(),"T0008","质量事故单 "+code,code+"  "+title+" 财务对单人已处理完毕;", CommonConstant.MSG_CATEGORY_2,taskParam);
 
 //		if(isComplete){
 

+ 6 - 5
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oa/service/impl/SyCarryServiceImpl.java

@@ -282,10 +282,10 @@ public class SyCarryServiceImpl extends ServiceImpl<SyCarryMapper, SyCarry> impl
 					iSysBaseAPI.sendSysAnnouncement(loginUser,loginUser.getUsername(),o.getUsername(),"搬运工对账单","您有一个新的搬运工对账单需要审批,请查看: "+syCarry.getName(), CommonConstant.MSG_CATEGORY_2,taskParam);
 				}
 				//财务总监角色
-				List<SysUser> getUserByRoleCode1 = sysUserService.getUserByRoleCode("SY008",null);
-				for(SysUser o:getUserByRoleCode1){
-					iSysBaseAPI.sendSysAnnouncement(loginUser,loginUser.getUsername(),o.getUsername(),"搬运工对账单","您有一个新的搬运工对账单需要审批,请查看: "+syCarry.getName(), CommonConstant.MSG_CATEGORY_2,taskParam);
-				}
+//				List<SysUser> getUserByRoleCode1 = sysUserService.getUserByRoleCode("SY008",null);
+//				for(SysUser o:getUserByRoleCode1){
+//					iSysBaseAPI.sendSysAnnouncement(loginUser,loginUser.getUsername(),o.getUsername(),"搬运工对账单","您有一个新的搬运工对账单需要审批,请查看: "+syCarry.getName(), CommonConstant.MSG_CATEGORY_2,taskParam);
+//				}
 
 				continue;
 			}
@@ -296,7 +296,8 @@ public class SyCarryServiceImpl extends ServiceImpl<SyCarryMapper, SyCarry> impl
 				boolean type = false;
 
 				for(String o:listRole){
-					if(o.equals("SY002") || o.equals("SY008")){ //SY002 财务经理 SY008财务总监角色
+//					if(o.equals("SY002") || o.equals("SY008")){ //SY002 财务经理 SY008财务总监角色
+					if(o.equals("SY002")){ //SY002 财务经理 SY008财务总监角色
 						type = true;
 					}
 				}

+ 2 - 1
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oa/service/impl/SyCottonYarnServiceImpl.java

@@ -144,7 +144,8 @@ public class SyCottonYarnServiceImpl extends ServiceImpl<SyCottonYarnMapper, SyC
 				boolean type = false;
 
 				for(String o:listRole){
-					if(o.equals("SY002") || o.equals("SY008")){ //SY002 财务经理 SY008财务总监角色
+//					if(o.equals("SY002") || o.equals("SY008")){ //SY002 财务经理 SY008财务总监角色
+					if(o.equals("SY002")){ //SY002 财务经理 SY008财务总监角色
 						type = true;
 					}
 				}

+ 3 - 0
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oa/vo/IncidentTicketPage.java

@@ -214,6 +214,9 @@ public class IncidentTicketPage {
 	@Excel(name = "1未处理 2已通知 3通知已反馈 4已推送 5已完结", width = 15)
 	@ApiModelProperty(value = "1未处理 2已通知 3通知已反馈 4已推送 5已完结")
 	private String state;
+	//未处理、已完结
+	@Excel(name = "单据状态", width = 15)
+	private String stateText;
 
 	@ExcelCollection(name="森_工厂质量事故单-子表")
 	@ApiModelProperty(value = "森_工厂质量事故单-子表")

+ 6 - 0
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oa/vo/SyCarryPage.java

@@ -90,6 +90,12 @@ public class SyCarryPage {
 	/**总计*/
 	@Excel(name = "总计", width = 15)
 	private Double totalNum;
+	@Excel(name = "备注", width = 15)
+	private String remarks;//备注2
+	/**总计(大写)*/
+	@Excel(name = "总计(大写)", width = 15)
+	private String totalText;//总计(大写)
+
 	@ExcelCollection(name="搬运装卸费用-搬运工对账单-子表")
 	private List<SyCarryB> syCarryBList;
 	

+ 42 - 0
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/SysAnnouncementController.java

@@ -1,6 +1,7 @@
 package org.jeecg.modules.system.controller;
 
 import java.io.IOException;
+import java.text.SimpleDateFormat;
 import java.util.Collection;
 import java.util.Date;
 import java.util.HashMap;
@@ -20,9 +21,12 @@ import org.jeecg.common.system.api.ISysBaseAPI;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.common.system.util.JwtUtil;
 import org.jeecg.common.system.vo.LoginUser;
+import org.jeecg.common.util.DateUtils;
 import org.jeecg.common.util.oConvertUtils;
 import org.jeecg.modules.message.websocket.WebSocket;
+import org.jeecg.modules.oa.entity.CdSchedule;
 import org.jeecg.modules.oa.entity.SyCertificates;
+import org.jeecg.modules.oa.mapper.CdScheduleMapper;
 import org.jeecg.modules.system.entity.SysAnnouncement;
 import org.jeecg.modules.system.entity.SysAnnouncementSend;
 import org.jeecg.modules.system.service.ISysAnnouncementSendService;
@@ -69,6 +73,8 @@ public class SysAnnouncementController {
     private WebSocket webSocket;
 	@Autowired
 	private ISysBaseAPI sysBaseAPI;
+	@Autowired
+	private CdScheduleMapper cdScheduleMapper;
 	/**
 	  * 分页列表查询
 	 * @param sysAnnouncement
@@ -297,7 +303,43 @@ public class SysAnnouncementController {
 		Result<Map<String,Object>> result = new Result<Map<String,Object>>();
 		LoginUser sysUser = (LoginUser)SecurityUtils.getSubject().getPrincipal();
 		String userId = sysUser.getId();
+		String username = sysUser.getUsername();
 		String pkOrg = sysUser.getPkOrg();
+
+		try {
+			List<CdSchedule> list = cdScheduleMapper.getListByUser(username);
+
+			if(list.size() > 0){
+				StringBuffer sb = new StringBuffer();
+				StringBuffer sb2 = new StringBuffer();
+				sb.append("亲爱的用户:").append(sysUser.getRealname()).append(",您今天有"+list.size()+"条新的日程计划,请及时查看。");
+				int ind = 1;
+				for (CdSchedule o:list){
+					sb2.append(ind+"、标题:").append(o.getTitle()).append("  日程时间:"+new SimpleDateFormat("yyyy-MM-dd").format(o.getStartTime()));
+					sb2.append("/"+new SimpleDateFormat("yyyy-MM-dd").format(o.getEndTime()));
+					if(o.getPlanTime() != null){
+						sb2.append("  时间:").append(new SimpleDateFormat("HH:mm:ss").format(o.getPlanTime())+";");
+					}
+					if(StringUtils.isNotBlank(o.getType())){
+						sb2.append("【"+o.getType()+"】");
+					}
+					if(StringUtils.isNotBlank(o.getDegreeOfUrgency())){
+						sb2.append("【"+o.getDegreeOfUrgency()+"】");
+					}
+
+					ind++;
+				}
+
+				LoginUser loginUser = sysBaseAPI.getUserByName("admin");
+				sysBaseAPI.sendSysAnnouncement(loginUser,"admin",username,"日程计划提醒",
+						"<h3>"+sb.toString()+"</h3><br> <h4><br>"+sb2.toString()+"</h4>",
+						CommonConstant.MSG_CATEGORY_2,new HashMap<>());
+				cdScheduleMapper.updateInfoNum(username);
+			}
+		}catch (Exception e){
+			System.out.println("日程消息发送失败:"+e.getMessage());
+		}
+
 		// 1.将系统消息补充到用户通告阅读标记表中
 		Collection<String> anntIds = sysAnnouncementSendService.queryByUserId(userId);
 		LambdaQueryWrapper<SysAnnouncement> querySaWrapper = new LambdaQueryWrapper<SysAnnouncement>();

+ 25 - 1
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/SysUserController.java

@@ -1402,6 +1402,9 @@ public class SysUserController {
         queryWrapper.orderByAsc("org_code");
         queryWrapper.orderByAsc("convert(realname using gbk)");
         IPage<SysUser> pageList = sysUserService.page(page, queryWrapper);
+        List<Map<String,String>> userNameList = new ArrayList<>();
+        List<Map<String,String>> userQCList = new ArrayList<>();
+        List<Map<String,String>> userYWList = new ArrayList<>();
         List<SysPosition> list2 = sysPositionService.list();
         Map<String,String> map = new HashMap<>();
         for(SysPosition o:list2){
@@ -1430,6 +1433,12 @@ public class SysUserController {
         if(userIds!=null && userIds.size()>0){
             Map<String,String>  useDepNames = sysUserService.getDepNamesByUserIds(userIds);
             pageList.getRecords().forEach(item->{
+
+                Map<String,String> userNameMap = new HashMap<>();
+                userNameMap.put("label",item.getRealname());
+                userNameMap.put("value",item.getRealname());
+                userNameList.add(userNameMap);
+
 //                pageList.getRecords().remove(item);
                 //TODO 临时借用这个字段用于页面展示
                 item.setOrgCode(useDepNames.get(item.getId()));
@@ -1453,6 +1462,17 @@ public class SysUserController {
                     item.setPost(map.get(item.getPost()));
                 }
 
+                if(item.getDeptName().startsWith("业务")){
+                    userYWList.add(userNameMap);
+                }
+                if(item.getDeptName().equals("海外成衣质检") ||
+                   item.getDeptName().endsWith("面料质检部") ||
+                   item.getDeptName().endsWith("成衣质检部") ||
+                   item.getDeptName().endsWith("QA部") ||
+                   item.getDeptName().endsWith("技术科")){
+                    userQCList.add(userNameMap);
+                }
+
             });
         }
         Collections.sort(pageList.getRecords(), (a, b) -> {
@@ -1474,6 +1494,9 @@ public class SysUserController {
         OtherSource other = new OtherSource();
         mapOne.put("supplierList",other.getSupplier("supplier"));
         mapOne.put("customerList",other.getSupplier("customer"));
+        mapOne.put("userNameList",userNameList);
+        mapOne.put("userYWList",userYWList);
+        mapOne.put("userQCList",userQCList);
         result.setData(mapOne);
 
         return result;
@@ -1523,7 +1546,7 @@ public class SysUserController {
             sysUserMapper.getNextNo(codeVo);
 
             if(name.equals("accidentCode")){
-                String nowDate = DateUtils.getDate("yyMMdd");
+                String nowDate = DateUtils.getDate("yyMM");
                 if(codeVo.getSeqNo() < 10){
                     return "TW"+nowDate+"-00"+codeVo.getSeqNo();
                 }else if(codeVo.getSeqNo() > 9 && codeVo.getSeqNo() < 100){
@@ -1544,6 +1567,7 @@ public class SysUserController {
         LocalDate with = LocalDate.now().with(TemporalAdjusters.firstDayOfMonth());
         String nowDate = DateUtils.getDate("yyyy-MM-dd");
         System.out.println(with.toString());
+        System.out.println(DateUtils.getDate("yyMM"));
         System.out.println(nowDate);
         System.out.println(nowDate.equals(with.toString()));