Enford 5 年之前
父節點
當前提交
546f2cc789
共有 83 個文件被更改,包括 21071 次插入0 次删除
  1. 19 0
      src/main/java/com/jeeplus/modules/worksalaryitem/dao/WorkSalaryItemDao.java
  2. 127 0
      src/main/java/com/jeeplus/modules/worksalaryitem/entity/WorkSalaryItem.java
  3. 54 0
      src/main/java/com/jeeplus/modules/worksalaryitem/service/WorkSalaryItemService.java
  4. 224 0
      src/main/java/com/jeeplus/modules/worksalaryitem/web/WorkSalaryItemController.java
  5. 33 0
      src/main/java/com/jeeplus/modules/workscrap/dao/WorkScrapDao.java
  6. 205 0
      src/main/java/com/jeeplus/modules/workscrap/entity/WorkScrap.java
  7. 675 0
      src/main/java/com/jeeplus/modules/workscrap/service/WorkScrapService.java
  8. 446 0
      src/main/java/com/jeeplus/modules/workscrap/web/WorkScrapController.java
  9. 52 0
      src/main/java/com/jeeplus/modules/worksealform/dao/WorkSealFormDao.java
  10. 440 0
      src/main/java/com/jeeplus/modules/worksealform/entity/WorkSealForm.java
  11. 832 0
      src/main/java/com/jeeplus/modules/worksealform/service/WorkSealFormService.java
  12. 355 0
      src/main/java/com/jeeplus/modules/worksealform/web/WorkSealFormController.java
  13. 32 0
      src/main/java/com/jeeplus/modules/worksendmessage/dao/WorkSendMessageDao.java
  14. 13 0
      src/main/java/com/jeeplus/modules/worksendmessage/dao/WorkSendMessageDetailDao.java
  15. 186 0
      src/main/java/com/jeeplus/modules/worksendmessage/entity/WorkSendMessage.java
  16. 734 0
      src/main/java/com/jeeplus/modules/worksendmessage/service/WorkSendMessageService.java
  17. 384 0
      src/main/java/com/jeeplus/modules/worksendmessage/web/WorkSendMessageController.java
  18. 30 0
      src/main/java/com/jeeplus/modules/worksinglewage/dao/WorkSingleWageDao.java
  19. 51 0
      src/main/java/com/jeeplus/modules/worksinglewage/dao/WorkSingleWageRecordDao.java
  20. 374 0
      src/main/java/com/jeeplus/modules/worksinglewage/entity/WorkSingleWage.java
  21. 63 0
      src/main/java/com/jeeplus/modules/worksinglewage/entity/WorkSingleWageRecord.java
  22. 683 0
      src/main/java/com/jeeplus/modules/worksinglewage/service/WorkSingleWageService.java
  23. 399 0
      src/main/java/com/jeeplus/modules/worksinglewage/web/WorkSingleWageController.java
  24. 19 0
      src/main/java/com/jeeplus/modules/workstaff/dao/WorkStaffAchievementDao.java
  25. 52 0
      src/main/java/com/jeeplus/modules/workstaff/dao/WorkStaffAchivesBackDao.java
  26. 58 0
      src/main/java/com/jeeplus/modules/workstaff/dao/WorkStaffAchivesDao.java
  27. 77 0
      src/main/java/com/jeeplus/modules/workstaff/dao/WorkStaffBasicInfoDao.java
  28. 19 0
      src/main/java/com/jeeplus/modules/workstaff/dao/WorkStaffCertificateDao.java
  29. 19 0
      src/main/java/com/jeeplus/modules/workstaff/dao/WorkStaffEducationDao.java
  30. 19 0
      src/main/java/com/jeeplus/modules/workstaff/dao/WorkStaffExperienceDao.java
  31. 19 0
      src/main/java/com/jeeplus/modules/workstaff/dao/WorkStaffFamilyDao.java
  32. 19 0
      src/main/java/com/jeeplus/modules/workstaff/dao/WorkStaffLanguagesDao.java
  33. 19 0
      src/main/java/com/jeeplus/modules/workstaff/dao/WorkStaffRecordDao.java
  34. 19 0
      src/main/java/com/jeeplus/modules/workstaff/dao/WorkStaffRewardsDao.java
  35. 19 0
      src/main/java/com/jeeplus/modules/workstaff/dao/WorkStaffSocialPositionDao.java
  36. 19 0
      src/main/java/com/jeeplus/modules/workstaff/dao/WorkStaffTitleDao.java
  37. 19 0
      src/main/java/com/jeeplus/modules/workstaff/dao/WorkStaffTrainingDao.java
  38. 97 0
      src/main/java/com/jeeplus/modules/workstaff/entity/WorkStaffAchievement.java
  39. 719 0
      src/main/java/com/jeeplus/modules/workstaff/entity/WorkStaffBasicInfo.java
  40. 160 0
      src/main/java/com/jeeplus/modules/workstaff/entity/WorkStaffCertificate.java
  41. 150 0
      src/main/java/com/jeeplus/modules/workstaff/entity/WorkStaffEducation.java
  42. 111 0
      src/main/java/com/jeeplus/modules/workstaff/entity/WorkStaffExperience.java
  43. 87 0
      src/main/java/com/jeeplus/modules/workstaff/entity/WorkStaffFamily.java
  44. 107 0
      src/main/java/com/jeeplus/modules/workstaff/entity/WorkStaffLanguages.java
  45. 96 0
      src/main/java/com/jeeplus/modules/workstaff/entity/WorkStaffRecord.java
  46. 97 0
      src/main/java/com/jeeplus/modules/workstaff/entity/WorkStaffRewards.java
  47. 81 0
      src/main/java/com/jeeplus/modules/workstaff/entity/WorkStaffSocialPosition.java
  48. 118 0
      src/main/java/com/jeeplus/modules/workstaff/entity/WorkStaffTitle.java
  49. 148 0
      src/main/java/com/jeeplus/modules/workstaff/entity/WorkStaffTraining.java
  50. 378 0
      src/main/java/com/jeeplus/modules/workstaff/service/WorkStaffAchievementService.java
  51. 929 0
      src/main/java/com/jeeplus/modules/workstaff/service/WorkStaffBasicInfoService.java
  52. 483 0
      src/main/java/com/jeeplus/modules/workstaff/service/WorkStaffCertificateService.java
  53. 483 0
      src/main/java/com/jeeplus/modules/workstaff/service/WorkStaffEducationService.java
  54. 389 0
      src/main/java/com/jeeplus/modules/workstaff/service/WorkStaffExperienceService.java
  55. 375 0
      src/main/java/com/jeeplus/modules/workstaff/service/WorkStaffFamilyService.java
  56. 470 0
      src/main/java/com/jeeplus/modules/workstaff/service/WorkStaffLanguagesService.java
  57. 443 0
      src/main/java/com/jeeplus/modules/workstaff/service/WorkStaffRecordService.java
  58. 380 0
      src/main/java/com/jeeplus/modules/workstaff/service/WorkStaffRewardsService.java
  59. 379 0
      src/main/java/com/jeeplus/modules/workstaff/service/WorkStaffSocialPositionService.java
  60. 429 0
      src/main/java/com/jeeplus/modules/workstaff/service/WorkStaffTitleService.java
  61. 449 0
      src/main/java/com/jeeplus/modules/workstaff/service/WorkStaffTrainingService.java
  62. 736 0
      src/main/java/com/jeeplus/modules/workstaff/web/WorkStaffBasicInfoController.java
  63. 24 0
      src/main/java/com/jeeplus/modules/workstaffachiveslog/dao/WorkStaffAchivesLogDao.java
  64. 157 0
      src/main/java/com/jeeplus/modules/workstaffachiveslog/entity/WorkStaffAchivesLog.java
  65. 91 0
      src/main/java/com/jeeplus/modules/workstaffachiveslog/service/WorkStaffAchivesLogService.java
  66. 196 0
      src/main/java/com/jeeplus/modules/workstaffachiveslog/web/WorkStaffAchivesLogController.java
  67. 30 0
      src/main/java/com/jeeplus/modules/workstock/dao/WorkStockDao.java
  68. 242 0
      src/main/java/com/jeeplus/modules/workstock/entity/WorkStock.java
  69. 912 0
      src/main/java/com/jeeplus/modules/workstock/service/WorkStockService.java
  70. 489 0
      src/main/java/com/jeeplus/modules/workstock/web/WorkStockController.java
  71. 35 0
      src/main/java/com/jeeplus/modules/workstockcontract/dao/WorkStockContractDao.java
  72. 281 0
      src/main/java/com/jeeplus/modules/workstockcontract/entity/WorkStockContract.java
  73. 761 0
      src/main/java/com/jeeplus/modules/workstockcontract/service/WorkStockContractService.java
  74. 410 0
      src/main/java/com/jeeplus/modules/workstockcontract/web/WorkStockContractController.java
  75. 23 0
      src/main/java/com/jeeplus/modules/worksupplier/dao/WorkSupplierDao.java
  76. 270 0
      src/main/java/com/jeeplus/modules/worksupplier/entity/WorkSupplier.java
  77. 107 0
      src/main/java/com/jeeplus/modules/worksupplier/service/WorkSupplierService.java
  78. 253 0
      src/main/java/com/jeeplus/modules/worksupplier/web/WorkSupplierController.java
  79. 41 0
      src/main/java/com/jeeplus/modules/workvisa/dao/WorkVisaDao.java
  80. 262 0
      src/main/java/com/jeeplus/modules/workvisa/entity/WorkVisa.java
  81. 550 0
      src/main/java/com/jeeplus/modules/workvisa/service/WorkVisaService.java
  82. 688 0
      src/main/java/com/jeeplus/modules/workvisa/web/WorkVisaController.java
  83. 148 0
      src/main/java/com/jeeplus/modules/workvisa/web/WorkVisaManageController.java

+ 19 - 0
src/main/java/com/jeeplus/modules/worksalaryitem/dao/WorkSalaryItemDao.java

@@ -0,0 +1,19 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.worksalaryitem.dao;
+
+import com.jeeplus.common.persistence.CrudDao;
+import com.jeeplus.common.persistence.annotation.MyBatisDao;
+import com.jeeplus.modules.worksalaryitem.entity.WorkSalaryItem;
+
+/**
+ * 工资项DAO接口
+ * @author ssrh
+ * @version 2018-09-17
+ */
+@MyBatisDao
+public interface WorkSalaryItemDao extends CrudDao<WorkSalaryItem> {
+
+	
+}

+ 127 - 0
src/main/java/com/jeeplus/modules/worksalaryitem/entity/WorkSalaryItem.java

@@ -0,0 +1,127 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.worksalaryitem.entity;
+
+
+import com.jeeplus.common.persistence.DataEntity;
+import com.jeeplus.common.utils.excel.annotation.ExcelField;
+
+/**
+ * 工资项Entity
+ * @author ssrh
+ * @version 2018-09-17
+ */
+public class WorkSalaryItem extends DataEntity<WorkSalaryItem> {
+	
+	private static final long serialVersionUID = 1L;
+	private String companyId;		// 公司
+	private String officeId;		// 部门
+	private String name;		// 工资项名称
+	private String num;		// 工资项编号
+	private String type;		// 工资项类型
+	private String setMethod;		// 设置方式
+	private String state;		// 禁用状态(1禁用2启用)
+	private String formula;		// 计算公式
+	private String explanation;		// 说 明
+	private String ids;		// 备用
+	
+	public WorkSalaryItem() {
+		super();
+	}
+
+	public WorkSalaryItem(String id){
+		super(id);
+	}
+
+	@ExcelField(title="公司", align=2, sort=7)
+	public String getCompanyId() {
+		return companyId;
+	}
+
+	public void setCompanyId(String companyId) {
+		this.companyId = companyId;
+	}
+	
+	@ExcelField(title="部门", align=2, sort=8)
+	public String getOfficeId() {
+		return officeId;
+	}
+
+	public void setOfficeId(String officeId) {
+		this.officeId = officeId;
+	}
+	
+	@ExcelField(title="工资项名称", align=2, sort=9)
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+	
+	@ExcelField(title="工资项编号", align=2, sort=10)
+	public String getNum() {
+		return num;
+	}
+
+	public void setNum(String num) {
+		this.num = num;
+	}
+	
+	@ExcelField(title="工资项类型", align=2, sort=11)
+	public String getType() {
+		return type;
+	}
+
+	public void setType(String type) {
+		this.type = type;
+	}
+	
+	@ExcelField(title="设置方式", align=2, sort=12)
+	public String getSetMethod() {
+		return setMethod;
+	}
+
+	public void setSetMethod(String setMethod) {
+		this.setMethod = setMethod;
+	}
+	
+	@ExcelField(title="禁用状态", align=2, sort=13)
+	public String getState() {
+		return state;
+	}
+
+	public void setState(String state) {
+		this.state = state;
+	}
+	
+	@ExcelField(title="计算公式", align=2, sort=14)
+	public String getFormula() {
+		return formula;
+	}
+
+	public void setFormula(String formula) {
+		this.formula = formula;
+	}
+	
+	@ExcelField(title="说 明", align=2, sort=15)
+	public String getExplanation() {
+		return explanation;
+	}
+
+	public void setExplanation(String explanation) {
+		this.explanation = explanation;
+	}
+	
+	@ExcelField(title="备用", align=2, sort=16)
+	public String getIds() {
+		return ids;
+	}
+
+	public void setIds(String ids) {
+		this.ids = ids;
+	}
+	
+}

+ 54 - 0
src/main/java/com/jeeplus/modules/worksalaryitem/service/WorkSalaryItemService.java

@@ -0,0 +1,54 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.worksalaryitem.service;
+
+import java.util.List;
+
+import com.jeeplus.common.utils.MenuStatusEnum;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.jeeplus.common.persistence.Page;
+import com.jeeplus.common.service.CrudService;
+import com.jeeplus.modules.worksalaryitem.entity.WorkSalaryItem;
+import com.jeeplus.modules.worksalaryitem.dao.WorkSalaryItemDao;
+
+/**
+ * 工资项Service
+ * @author ssrh
+ * @version 2018-09-17
+ */
+@Service
+@Transactional(readOnly = true)
+public class WorkSalaryItemService extends CrudService<WorkSalaryItemDao, WorkSalaryItem> {
+
+	public WorkSalaryItem get(String id) {
+		return super.get(id);
+	}
+	
+	public List<WorkSalaryItem> findList(WorkSalaryItem workSalaryItem) {
+		return super.findList(workSalaryItem);
+	}
+	
+	public Page<WorkSalaryItem> findPage(Page<WorkSalaryItem> page, WorkSalaryItem workSalaryItem) {
+		workSalaryItem.getSqlMap().put("dsf", dataScopeFilter(workSalaryItem.getCurrentUser(), "o", "u","s", MenuStatusEnum.WORK_SALARYITEM.getValue()));
+		workSalaryItem.setPage(page);
+		page.setList(findList(workSalaryItem));
+		return page;
+	}
+	
+	@Transactional(readOnly = false)
+	public void save(WorkSalaryItem workSalaryItem) {
+		super.save(workSalaryItem);
+	}
+	
+	@Transactional(readOnly = false)
+	public void delete(WorkSalaryItem workSalaryItem) {
+		super.delete(workSalaryItem);
+	}
+	
+	
+	
+	
+}

+ 224 - 0
src/main/java/com/jeeplus/modules/worksalaryitem/web/WorkSalaryItemController.java

@@ -0,0 +1,224 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.worksalaryitem.web;
+
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.validation.ConstraintViolationException;
+
+import com.jeeplus.modules.sys.utils.UserUtils;
+import org.apache.shiro.authz.annotation.Logical;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.servlet.mvc.support.RedirectAttributes;
+
+import com.google.common.collect.Lists;
+import com.jeeplus.common.utils.DateUtils;
+import com.jeeplus.common.utils.MyBeanUtils;
+import com.jeeplus.common.config.Global;
+import com.jeeplus.common.persistence.Page;
+import com.jeeplus.common.web.BaseController;
+import com.jeeplus.common.utils.StringUtils;
+import com.jeeplus.common.utils.excel.ExportExcel;
+import com.jeeplus.common.utils.excel.ImportExcel;
+import com.jeeplus.modules.worksalaryitem.entity.WorkSalaryItem;
+import com.jeeplus.modules.worksalaryitem.service.WorkSalaryItemService;
+
+/**
+ * 工资项Controller
+ * @author ssrh
+ * @version 2018-09-17
+ */
+@Controller
+@RequestMapping(value = "${adminPath}/worksalaryitem/workSalaryItem")
+public class WorkSalaryItemController extends BaseController {
+
+	@Autowired
+	private WorkSalaryItemService workSalaryItemService;
+	@Autowired
+	private HttpServletRequest request;
+	@ModelAttribute
+	public WorkSalaryItem get(@RequestParam(required=false) String id) {
+		WorkSalaryItem entity = null;
+		if (StringUtils.isNotBlank(id)){
+			entity = workSalaryItemService.get(id);
+		}
+		if (entity == null){
+			entity = new WorkSalaryItem();
+		}
+		return entity;
+	}
+	
+	/**
+	 * 工资项列表页面
+	 */
+	@RequiresPermissions("worksalaryitem:workSalaryItem:list")
+	@RequestMapping(value = {"list", ""})
+	public String list(WorkSalaryItem workSalaryItem, HttpServletRequest request, HttpServletResponse response, Model model) {
+		Page<WorkSalaryItem> page = workSalaryItemService.findPage(new Page<WorkSalaryItem>(request, response), workSalaryItem); 
+		model.addAttribute("page", page);
+		return "modules/worksalaryitem/workSalaryItemList";
+	}
+
+	/**
+	 * 查看,增加,编辑工资项表单页面
+	 */
+	@RequiresPermissions(value={"worksalaryitem:workSalaryItem:view","worksalaryitem:workSalaryItem:add","worksalaryitem:workSalaryItem:edit"},logical=Logical.OR)
+	@RequestMapping(value = "form")
+	public String form(WorkSalaryItem workSalaryItem, Model model) {
+		String tabId = request.getParameter("tabId");
+		if("1".equals(tabId)){
+			model.addAttribute("workSalaryItem", workSalaryItem);
+			return "modules/worksalaryitem/workSalaryItemView";
+		}
+		if(StringUtils.isBlank(workSalaryItem.getId())){
+			workSalaryItem.setState("2");
+		}
+		model.addAttribute("workSalaryItem", workSalaryItem);
+		return "modules/worksalaryitem/workSalaryItemForm";
+	}
+
+	/**
+	 * 保存工资项
+	 */
+	@RequiresPermissions(value={"worksalaryitem:workSalaryItem:add","worksalaryitem:workSalaryItem:edit"},logical=Logical.OR)
+	@RequestMapping(value = "save")
+	public String save(WorkSalaryItem workSalaryItem, Model model, RedirectAttributes redirectAttributes) throws Exception{
+		if (!beanValidator(model, workSalaryItem)){
+			return form(workSalaryItem, model);
+		}
+		if(!workSalaryItem.getIsNewRecord()){//编辑表单保存
+			WorkSalaryItem t = workSalaryItemService.get(workSalaryItem.getId());//从数据库取出记录的值
+			MyBeanUtils.copyBeanNotNull2Bean(workSalaryItem, t);//将编辑表单中的非NULL值覆盖数据库记录中的值
+			workSalaryItemService.save(t);//保存
+		}else{//新增表单保存
+			workSalaryItem.setCompanyId(UserUtils.getSelectCompany().getId());
+			workSalaryItem.setOfficeId(UserUtils.getSelectOffice().getId());
+			//状态 默认启用
+			workSalaryItem.setState("2");
+			workSalaryItemService.save(workSalaryItem);//保存
+		}
+		addMessage(redirectAttributes, "保存工资项成功");
+		return "redirect:"+Global.getAdminPath()+"/worksalaryitem/workSalaryItem/?repage";
+	}
+	
+	/**
+	 * 删除工资项
+	 */
+	@RequiresPermissions("worksalaryitem:workSalaryItem:del")
+	@RequestMapping(value = "delete")
+	public String delete(WorkSalaryItem workSalaryItem, RedirectAttributes redirectAttributes) {
+		workSalaryItemService.delete(workSalaryItem);
+		addMessage(redirectAttributes, "删除工资项成功");
+		return "redirect:"+Global.getAdminPath()+"/worksalaryitem/workSalaryItem/?repage";
+	}
+	@RequiresPermissions("worksalaryitem:workSalaryItem:edit")
+	@RequestMapping(value = "edits")
+	public String edits(WorkSalaryItem workSalaryItem, RedirectAttributes redirectAttributes) {
+		String tabId = request.getParameter("tabId");
+		if("3".equals(tabId)){
+			//禁用
+			workSalaryItem.setState("1");
+		}else if("4".equals(tabId)){
+			//启用
+			workSalaryItem.setState("2");
+		}
+		workSalaryItemService.save(workSalaryItem);
+		addMessage(redirectAttributes, "更新成功");
+		return "redirect:"+Global.getAdminPath()+"/worksalaryitem/workSalaryItem/?repage";
+	}
+	/**
+	 * 批量删除工资项
+	 */
+	@RequiresPermissions("worksalaryitem:workSalaryItem:del")
+	@RequestMapping(value = "deleteAll")
+	public String deleteAll(String ids, RedirectAttributes redirectAttributes) {
+		String idArray[] =ids.split(",");
+		for(String id : idArray){
+			workSalaryItemService.delete(workSalaryItemService.get(id));
+		}
+		addMessage(redirectAttributes, "删除工资项成功");
+		return "redirect:"+Global.getAdminPath()+"/worksalaryitem/workSalaryItem/?repage";
+	}
+	
+	/**
+	 * 导出excel文件
+	 */
+	@RequiresPermissions("worksalaryitem:workSalaryItem:export")
+    @RequestMapping(value = "export", method=RequestMethod.POST)
+    public String exportFile(WorkSalaryItem workSalaryItem, HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) {
+		try {
+            String fileName = "工资项"+DateUtils.getDate("yyyyMMddHHmmss")+".xlsx";
+            Page<WorkSalaryItem> page = workSalaryItemService.findPage(new Page<WorkSalaryItem>(request, response, -1), workSalaryItem);
+    		new ExportExcel("工资项", WorkSalaryItem.class).setDataList(page.getList()).write(response, fileName).dispose();
+    		return null;
+		} catch (Exception e) {
+			addMessage(redirectAttributes, "导出工资项记录失败!失败信息:"+e.getMessage());
+		}
+		return "redirect:"+Global.getAdminPath()+"/worksalaryitem/workSalaryItem/?repage";
+    }
+
+	/**
+	 * 导入Excel数据
+
+	 */
+	@RequiresPermissions("worksalaryitem:workSalaryItem:import")
+    @RequestMapping(value = "import", method=RequestMethod.POST)
+    public String importFile(MultipartFile file, RedirectAttributes redirectAttributes) {
+		try {
+			int successNum = 0;
+			int failureNum = 0;
+			StringBuilder failureMsg = new StringBuilder();
+			ImportExcel ei = new ImportExcel(file, 1, 0);
+			List<WorkSalaryItem> list = ei.getDataList(WorkSalaryItem.class);
+			for (WorkSalaryItem workSalaryItem : list){
+				try{
+					workSalaryItemService.save(workSalaryItem);
+					successNum++;
+				}catch(ConstraintViolationException ex){
+					failureNum++;
+				}catch (Exception ex) {
+					failureNum++;
+				}
+			}
+			if (failureNum>0){
+				failureMsg.insert(0, ",失败 "+failureNum+" 条工资项记录。");
+			}
+			addMessage(redirectAttributes, "已成功导入 "+successNum+" 条工资项记录"+failureMsg);
+		} catch (Exception e) {
+			addMessage(redirectAttributes, "导入工资项失败!失败信息:"+e.getMessage());
+		}
+		return "redirect:"+Global.getAdminPath()+"/worksalaryitem/workSalaryItem/?repage";
+    }
+	
+	/**
+	 * 下载导入工资项数据模板
+	 */
+	@RequiresPermissions("worksalaryitem:workSalaryItem:import")
+    @RequestMapping(value = "import/template")
+    public String importFileTemplate(HttpServletResponse response, RedirectAttributes redirectAttributes) {
+		try {
+            String fileName = "工资项数据导入模板.xlsx";
+    		List<WorkSalaryItem> list = Lists.newArrayList(); 
+    		new ExportExcel("工资项数据", WorkSalaryItem.class, 1).setDataList(list).write(response, fileName).dispose();
+    		return null;
+		} catch (Exception e) {
+			addMessage(redirectAttributes, "导入模板下载失败!失败信息:"+e.getMessage());
+		}
+		return "redirect:"+Global.getAdminPath()+"/worksalaryitem/workSalaryItem/?repage";
+    }
+	
+	
+	
+
+}

+ 33 - 0
src/main/java/com/jeeplus/modules/workscrap/dao/WorkScrapDao.java

@@ -0,0 +1,33 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workscrap.dao;
+
+import com.jeeplus.modules.workitem.entity.WorkItem;
+import java.util.List;
+import com.jeeplus.common.persistence.CrudDao;
+import com.jeeplus.common.persistence.annotation.MyBatisDao;
+import com.jeeplus.modules.workscrap.entity.WorkScrap;
+
+/**
+ * 报废管理DAO接口
+ * @author lw
+ * @version 2018-07-16
+ */
+@MyBatisDao
+public interface WorkScrapDao extends CrudDao<WorkScrap> {
+	/**
+	 * 更新流程实例ID
+	 * @return
+	 */
+	public int updateProcessInstanceId(WorkScrap workScrap);
+
+	/**
+	 * 根据流程实例ID获取
+	 * @param processInstanceId
+	 * @return
+	 */
+	public WorkScrap getByProcessInstanceId(String processInstanceId);
+	public List<WorkItem> findListByitem(WorkItem item);
+	
+}

+ 205 - 0
src/main/java/com/jeeplus/modules/workscrap/entity/WorkScrap.java

@@ -0,0 +1,205 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workscrap.entity;
+
+import java.util.Date;
+import java.util.Map;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.jeeplus.common.persistence.ActEntity;
+import com.jeeplus.modules.workitem.entity.WorkItem;
+
+import com.jeeplus.common.persistence.DataEntity;
+import com.jeeplus.common.utils.excel.annotation.ExcelField;
+import org.activiti.engine.history.HistoricProcessInstance;
+import org.activiti.engine.repository.ProcessDefinition;
+import org.activiti.engine.runtime.ProcessInstance;
+import org.activiti.engine.task.Task;
+
+/**
+ * 报废管理Entity
+ * @author lw
+ * @version 2018-07-16
+ */
+public class WorkScrap extends ActEntity<WorkScrap> {
+	// ggh3125f1f194c82bfglcggldc750904    //63
+	private static final long serialVersionUID = 1L;
+	public static final String SERIAL_BIZCODE = "16";//编号模板类型
+	private String processInstanceId;		// 流程号
+	private String officeId;		// 部门
+	private String companyId;		// 公司
+	private String status;		// 状态
+	private String number;		// 报废编号
+	private String officeName;		// 所属部门
+	private Date scrapDate;		// 报废日期
+	private String reason;		// 报废事由
+	private WorkItem item;		// 固定资产
+
+	private Date beginContractDate;		// 开始
+	private Date endContractDate;		// 结束
+	private String home;
+	// 流程任务
+	private Task task;
+	private Map<String, Object> variables;
+	// 运行中的流程实例
+	private ProcessInstance processInstance;
+	// 历史的流程实例
+	private HistoricProcessInstance historicProcessInstance;
+	// 流程定义
+	private ProcessDefinition processDefinition;
+
+	public WorkScrap() {
+		super();
+	}
+
+	public WorkScrap(String id){
+		super(id);
+	}
+
+	@ExcelField(title="流程号", align=2, sort=7)
+	public String getProcessInstanceId() {
+		return processInstanceId;
+	}
+
+	public void setProcessInstanceId(String processInstanceId) {
+		this.processInstanceId = processInstanceId;
+	}
+
+	@ExcelField(title="部门", align=2, sort=8)
+	public String getOfficeId() {
+		return officeId;
+	}
+
+	public void setOfficeId(String officeId) {
+		this.officeId = officeId;
+	}
+
+	@ExcelField(title="公司", align=2, sort=9)
+	public String getCompanyId() {
+		return companyId;
+	}
+
+	public void setCompanyId(String companyId) {
+		this.companyId = companyId;
+	}
+
+	@ExcelField(title="状态", align=2, sort=10)
+	public String getStatus() {
+		return status;
+	}
+
+	public void setStatus(String status) {
+		this.status = status;
+	}
+
+	@ExcelField(title="报废编号", align=2, sort=11)
+	public String getNumber() {
+		return number;
+	}
+
+	public void setNumber(String number) {
+		this.number = number;
+	}
+
+	@ExcelField(title="所属部门", align=2, sort=12)
+	public String getOfficeName() {
+		return officeName;
+	}
+
+	public void setOfficeName(String officeName) {
+		this.officeName = officeName;
+	}
+
+	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+	@ExcelField(title="报废日期", align=2, sort=13)
+	public Date getScrapDate() {
+		return scrapDate;
+	}
+
+	public void setScrapDate(Date scrapDate) {
+		this.scrapDate = scrapDate;
+	}
+
+	@ExcelField(title="报废事由", align=2, sort=14)
+	public String getReason() {
+		return reason;
+	}
+
+	public void setReason(String reason) {
+		this.reason = reason;
+	}
+
+	@ExcelField(title="固定资产", align=2, sort=15)
+	public WorkItem getItem() {
+		return item;
+	}
+
+	public void setItem(WorkItem item) {
+		this.item = item;
+	}
+
+	public Date getBeginContractDate() {
+		return beginContractDate;
+	}
+
+	public void setBeginContractDate(Date beginContractDate) {
+		this.beginContractDate = beginContractDate;
+	}
+
+	public Date getEndContractDate() {
+		return endContractDate;
+	}
+
+	public void setEndContractDate(Date endContractDate) {
+		this.endContractDate = endContractDate;
+	}
+
+	public String getHome() {
+		return home;
+	}
+
+	public void setHome(String home) {
+		this.home = home;
+	}
+
+	public Task getTask() {
+		return task;
+	}
+
+	public void setTask(Task task) {
+		this.task = task;
+	}
+
+	public Map<String, Object> getVariables() {
+		return variables;
+	}
+
+	public void setVariables(Map<String, Object> variables) {
+		this.variables = variables;
+	}
+
+	public ProcessInstance getProcessInstance() {
+		return processInstance;
+	}
+
+	public void setProcessInstance(ProcessInstance processInstance) {
+		this.processInstance = processInstance;
+	}
+
+	public HistoricProcessInstance getHistoricProcessInstance() {
+		return historicProcessInstance;
+	}
+
+	public void setHistoricProcessInstance(HistoricProcessInstance historicProcessInstance) {
+		this.historicProcessInstance = historicProcessInstance;
+	}
+
+	public ProcessDefinition getProcessDefinition() {
+		return processDefinition;
+	}
+
+	public void setProcessDefinition(ProcessDefinition processDefinition) {
+		this.processDefinition = processDefinition;
+	}
+}

+ 675 - 0
src/main/java/com/jeeplus/modules/workscrap/service/WorkScrapService.java

@@ -0,0 +1,675 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workscrap.service;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.google.common.collect.Maps;
+import com.jeeplus.common.utils.DateUtils;
+import com.jeeplus.common.utils.MenuStatusEnum;
+import com.jeeplus.common.utils.StringUtils;
+import com.jeeplus.common.websocket.onchat.ChatServerPool;
+import com.jeeplus.modules.act.service.ActTaskService;
+import com.jeeplus.modules.act.utils.ActUtils;
+import com.jeeplus.modules.projectrecord.dao.WorkProjectUserDao;
+import com.jeeplus.modules.serialnum.service.SerialNumTplService;
+import com.jeeplus.modules.sys.entity.Office;
+import com.jeeplus.modules.sys.entity.User;
+import com.jeeplus.modules.sys.utils.UserUtils;
+import com.jeeplus.modules.workactivity.dao.WorkActivityProcessDao;
+import com.jeeplus.modules.workactivity.entity.Activity;
+import com.jeeplus.modules.workactivity.entity.WorkActivityProcess;
+import com.jeeplus.modules.workactivity.service.ActivityService;
+import com.jeeplus.modules.workactivity.service.WorkActivityProcessService;
+import com.jeeplus.modules.workactivitymenu.entity.WorkActivityMenu;
+import com.jeeplus.modules.workactivitymenu.service.WorkActivityMenuService;
+import com.jeeplus.modules.workcatalogueitem.entity.WorkCatalogueItem;
+import com.jeeplus.modules.workcatalogueitem.service.WorkCatalogueItemService;
+import com.jeeplus.modules.workclientinfo.dao.WorkClientAttachmentDao;
+import com.jeeplus.modules.workitem.service.WorkItemService;
+import com.jeeplus.modules.workprojectnotify.entity.WorkProjectNotify;
+import com.jeeplus.modules.workprojectnotify.service.WorkProjectNotifyService;
+import com.jeeplus.modules.workprojectnotify.util.UtilNotify;
+import com.jeeplus.modules.workreimbursement.dao.ReimbursementVATTaxDao;
+import com.jeeplus.modules.workreimbursement.dao.WorkAccountDao;
+import com.jeeplus.modules.workreimbursement.dao.WorkReimbursementDao;
+import org.activiti.engine.*;
+import org.activiti.engine.runtime.ProcessInstance;
+import org.java_websocket.WebSocket;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.jeeplus.modules.workitem.entity.WorkItem;
+import com.jeeplus.common.persistence.Page;
+import com.jeeplus.common.service.CrudService;
+import com.jeeplus.modules.workscrap.entity.WorkScrap;
+import com.jeeplus.modules.workscrap.dao.WorkScrapDao;
+
+/**
+ * 报废管理Service
+ * @author lw
+ * @version 2018-07-16
+ */
+@Service
+@Transactional(readOnly = true)
+public class WorkScrapService extends CrudService<WorkScrapDao, WorkScrap> {
+	@Autowired
+	private RuntimeService runtimeService;
+	@Autowired
+	protected TaskService taskService;
+	@Autowired
+	protected HistoryService historyService;
+	@Autowired
+	protected RepositoryService repositoryService;
+	@Autowired
+	private IdentityService identityService;
+	@Autowired
+	private ActTaskService actTaskService;
+	@Autowired
+	private WorkProjectNotifyService workProjectNotifyService;
+	@Autowired
+	private WorkActivityMenuService workActivityMenuService;
+	@Autowired
+	private WorkActivityProcessService workActivityProcessService;
+	@Autowired
+	private ActivityService activityService;
+	@Autowired
+	private WorkActivityProcessDao workActivityProcessDao;
+	@Autowired
+	private SerialNumTplService serialNumTplService;
+	@Autowired
+	private WorkScrapDao workScrapDao;
+	@Autowired
+	private WorkItemService workItemService;
+	@Autowired
+	private WorkCatalogueItemService workCatalogueItemService;
+	public WorkScrap get(String id) {
+		WorkScrap workScrap = super.get(id);
+		//补充固定资产详细信息
+		if(workScrap!=null){
+			if(workScrap.getItem()!=null){
+				String itemId = workScrap.getItem().getId();
+				if(StringUtils.isNotBlank(itemId)){
+					WorkItem workItem = workItemService.get(itemId);
+					if(workItem!=null){
+						if(workItem.getWorkCatalogueItem()!=null){
+							String cItemId = workItem.getWorkCatalogueItem().getId();
+							if(StringUtils.isNotBlank(cItemId)){
+								WorkCatalogueItem workCatalogueItem = workCatalogueItemService.get(cItemId);
+								workItem.setWorkCatalogueItem(workCatalogueItem);
+								workScrap.setItem(workItem);
+							}
+						}
+					}
+				}
+			}
+		}
+		return workScrap;
+	}
+
+	public List<WorkScrap> findList(WorkScrap workScrap) {
+		return super.findList(workScrap);
+	}
+
+	public Page<WorkScrap> findPage(Page<WorkScrap> page, WorkScrap workScrap) {
+		workScrap.getSqlMap().put("dsf", dataScopeFilter(workScrap.getCurrentUser(), "o", "u","s", MenuStatusEnum.WORK_SCRAP.getValue()));
+		workScrap.setPage(page);
+		page.setList(findList(workScrap));
+		return page;
+	}
+
+	@Transactional(readOnly = false)
+	public void save(WorkScrap workScrap) {
+		super.save(workScrap);
+	}
+
+	/**
+	 * 提交存储
+	 * @param workScrap
+	 * @param variables
+	 */
+	@Transactional(readOnly = false)
+	public String save(WorkScrap workScrap, Map<String, Object> variables, String processInstanceId) {
+		User user = UserUtils.getUser();
+		if (StringUtils.isBlank(workScrap.getNumber())) {
+			workScrap.setNumber(serialNumTplService.genSerialNum(user.getCompany(), workScrap.SERIAL_BIZCODE));
+		}
+		super.save(workScrap);
+		String str = "";
+		if(workScrap.getItem()!=null && workScrap.getItem().getWorkCatalogueItem()!=null){
+			str = "报废编码:"+workScrap.getNumber()+",报废日期:"+ DateUtils.formatDate(workScrap.getScrapDate())+",物品名称:"+workScrap.getItem().getItemName();
+		}else{
+			str = "报废编码:"+workScrap.getNumber()+",报废日期:"+ DateUtils.formatDate(workScrap.getScrapDate());
+		}
+		String title = "物品报废申请人:"+user.getName();
+		// 用来设置启动流程的人员ID,引擎会自动把用户ID保存到activiti:initiator中
+		identityService.setAuthenticatedUserId(user.getId());
+		// 启动流程
+		String businessKey = workScrap.getId().toString();
+		Office office = UserUtils.getSelectOffice();
+		WorkActivityMenu workActivityMenu = workActivityMenuService.findByParentAndOffice("ggh3125f1f194c82bfglcggldc750904", office);
+		// 启动流程
+		String processType = workActivityMenu.getProcessType();
+		StringBuffer buffer = new StringBuffer();
+		Activity activity = new Activity();
+		WorkProjectNotify workProjectNotify = UtilNotify
+				.saveNotify(workScrap.getId(),
+						null,
+						workScrap.getCompanyId(),
+						title,
+						str,
+						"63",
+						"0",
+						"待审批",
+						""
+				);
+		List<User> users = new ArrayList<>();
+		List<User> xzbzrs = UserUtils.getByRoleActivityEnname("xzbzr",3,office.getId(),"15",workScrap.getCreateBy());
+		if (StringUtils.isNotBlank(workActivityMenu.getId())) {
+			workProjectNotify.setNotifyRole("");
+			workActivityMenu = workActivityMenuService.get(workActivityMenu.getId());
+			List<Activity> activities = workActivityMenu.getActivities();
+			for (Activity a : activities) {
+				String encount = a.getEncount();
+				String enlist = a.getEnlist();
+				if (a.getRole()!=null && StringUtils.isNotBlank(a.getRole().getEnname())){
+					List enusers = UserUtils.getByRoleActivityEnnames(a.getRole().getEnname(),office.getId(),"15",workScrap.getCreateBy());
+					if (enusers.size()==0){
+						workScrap.setStatus("1");
+						super.save(workScrap);
+						return "流程审批人不能为空,角色"+a.getRole().getName()+"下无用户,请联系管理员!";
+					}
+					variables.put(enlist, enusers);
+					variables.put(encount, enusers.size());
+				}
+				if (a.getDelFlag().equals("0") && a.getCount() == 1) {
+					activity = a;
+				}
+			}
+			buffer.append(activity.getRole().getEnname());
+			if (activity != null && StringUtils.isNotBlank(activity.getId())) {
+				//角色审批
+				if (StringUtils.isNotBlank(activity.getRole().getEnname())) {
+					users = UserUtils.getByRoleActivityEnnames(activity.getRole().getEnname(),office.getId(),"15",workScrap.getCreateBy());
+				}
+				//人员审批
+				if (StringUtils.isNotBlank(activity.getUser().getId())) {
+					users.add(activity.getUser());
+				}
+			}
+			workProjectNotify.setId("");
+		} else {
+			variables.put("xzbzrList", xzbzrs);
+			if (xzbzrs.size()==0 ){
+				workScrap.setStatus("1");
+				super.save(workScrap);
+			}
+			if (xzbzrs.size()==0){
+				return "流程审批人不能为空,角色行政部负责人下无用户,请联系管理员!";
+			}
+			variables.put("xzbzrcount",xzbzrs.size());
+			processType = "workscrap";
+			users.addAll(xzbzrs);
+		}
+		for (User u : users){
+			workProjectNotify.setUser(u);
+			workProjectNotify.setId("");
+			workProjectNotify.setNotifyRole("行政部负责人审批");
+			workProjectNotifyService
+					.save(workProjectNotify);
+			Map<String,Object> extras = new HashMap<>();
+			extras.put("type","7001");
+			extras.put("id",workProjectNotify.getId());
+			extras.put("procDefKey","63");
+			UserUtils.pushInfoToApp(title,str,extras,u.getId());
+			UserUtils.pushIm(u.getId(),str);
+		}
+		variables.put("type", processType);
+		variables.put("busId", businessKey);
+		variables.put("title", "审批单:" + workScrap.getNumber());//设置标题;
+
+		ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(processType, businessKey, variables);
+		workScrap.setProcessInstance(processInstance);
+		if (StringUtils.isNotBlank(processInstanceId)) {
+			workActivityProcessService.updateProcessInstanceId(processInstance.getId(),processInstanceId);
+			workActivityProcessService.deleteProcessInstanceId(processInstanceId);
+			workActivityProcessService.deleteProcessIdAuditUsers(processInstanceId);
+		}
+		// 更新流程实例ID
+		workScrap.setProcessInstanceId(processInstance.getId());
+		workScrapDao.updateProcessInstanceId(workScrap);
+		List<Activity> list = workActivityMenu.getActivities();
+		if (list != null && list.size() != 0) {
+			workActivityProcessService.saveList(list, processInstance.getId());
+		} else {
+			WorkActivityProcess workActivityProcess = new WorkActivityProcess();
+			workActivityProcess.setProcessKey("workscrap");
+			workActivityProcess.setCount(1);
+			workActivityProcess.setProcessInstanceId(processInstance.getId());
+			workActivityProcess.setIsApproval("0");
+			workActivityProcessService.save(workActivityProcess);
+			workActivityProcessService.insertAuditsByType(xzbzrs,processInstance.getId(),1,1);
+		}
+		logger.debug("start process of {key={}, bkey={}, pid={}, variables={}}", new Object[]{
+				ActUtils.PD_REIMBURSEMENT[0], businessKey, processInstance.getId(), variables});
+		return "";
+	}
+	@Transactional(readOnly = false)
+	public void delete(WorkScrap workScrap) {
+		super.delete(workScrap);
+		WorkProjectNotify notify = new WorkProjectNotify();
+		notify.setNotifyId(workScrap.getId());
+		workProjectNotifyService.readByNotifyId(notify);
+	}
+
+	public Page<WorkItem> findPageByitem(Page<WorkItem> page, WorkItem item) {
+		item.setPage(page);
+		page.setList(dao.findListByitem(item));
+		return page;
+	}
+
+	/**
+	 * 审核流程
+	 * @param
+	 */
+	@Transactional(readOnly = false)
+	public String auditSave(WorkScrap workScrap,List<User> auditUsers) {
+		String userName = UserUtils.get(workScrap.getCreateBy().getId()).getName();
+		String str = "";
+		if(workScrap.getItem()!=null && workScrap.getItem().getWorkCatalogueItem()!=null){
+			str = "报废编码:"+workScrap.getNumber()+",报废日期:"+ DateUtils.formatDate(workScrap.getScrapDate())+",物品名称:"+workScrap.getItem().getWorkCatalogueItem().getName();
+		}else{
+			str = "报废编码:"+workScrap.getNumber()+",报废日期:"+ DateUtils.formatDate(workScrap.getScrapDate());
+		}
+		String title = "物品报废申请人:"+userName;
+		// 对不同环节的业务逻辑进行操作
+		String taskDefKey = workScrap.getAct().getTaskDefKey();
+		if (!"modifyApply".equals(taskDefKey)) {
+			actTaskService.claim(workScrap.getAct().getTaskId(), UserUtils.getUser().getId());
+		}else {
+			workScrap.getAct().setFlag("yes");
+		}
+		String comment = "";
+		if (workScrap.getStatus().equals("4")){
+			comment = ("yes".equals(workScrap.getAct().getFlag())?"[重新申请] ":"[已撤销] ");
+		}else {
+			comment = ("yes".equals(workScrap.getAct().getFlag())?"[同意] ":"[驳回] ")+workScrap.getAct().getComment();
+		}
+		//yes 的时候状态为审核通过 否则为未通过
+		//1 审核中 2 未通过
+		workScrap.setStatus(("yes".equals(workScrap.getAct().getFlag()) ? "2" : "4"));
+		//String buffer = UserUtils.getRoleActivityEnname(UserUtils.getSelectCompany().getId(),workScrap.getCreateBy());
+		Map<String, Object> vars = Maps.newHashMap();
+		//业务逻辑对应的条件表达式
+		String exp = "";
+		String taskCount = "";
+		String notifyRole = "";
+		int key = 0;
+		String enname = "";
+		List<Activity> activitieList = activityService.getByProcessInstanceId(workScrap.getProcessInstanceId());
+		WorkActivityMenu workActivityMenu = new WorkActivityMenu();
+		if (activitieList != null && activitieList.size() != 0) {
+			workActivityMenu.setProcessType(activitieList.get(0).getProcessKey());
+			workActivityMenu.setActivities(activitieList);
+		}
+
+		WorkActivityProcess workActivityProcess = new WorkActivityProcess();
+		WorkActivityProcess selectProcess = new WorkActivityProcess();
+		selectProcess.setProcessInstanceId(workScrap.getProcessInstanceId());
+		List<WorkActivityProcess> workActivityProcesses = workActivityProcessService.findList(selectProcess);
+		List<Activity> activities = workActivityMenu.getActivities();
+		if (StringUtils.isNotBlank(workActivityMenu.getProcessType()) && !workActivityMenu.getProcessType().equals("workscrap")) {
+			key = 1;
+			for (int i = 0; i < workActivityProcesses.size(); i++) {
+				WorkActivityProcess activityProcess = workActivityProcesses.get(i);
+				if (taskDefKey.equals(activityProcess.getActivityTask()) && !taskDefKey.equals("modifyApply")) {
+					taskCount = activityProcess.getCount()+"";
+					workActivityProcess = activityProcess;
+					if (!workActivityProcess.getIsApproval().equals("0")) {
+						workActivityProcess.setId("");
+					}
+					exp = "pass";
+					if (!"yes".equals(workScrap.getAct().getFlag())) {
+						workScrap.setStatus("4");
+						workActivityProcess.setIsApproval("2");
+						String returnBack = "-1";
+						for (Activity activity : activities) {
+							if (activity.getCount() == activityProcess.getCount()) {
+								notifyRole = activity.getName();
+								returnBack = activity.getReturnBack();
+								break;
+							}
+						}
+						if (returnBack.equals("0")) {
+							workActivityProcess.setId("");
+						}
+
+					} else {
+						workActivityProcess.setIsApproval("1");
+					}
+				}else if(taskDefKey.equals("modifyApply")){
+					notifyRole = "调整申请";
+					taskCount = "0";
+					exp = "pass";
+					workActivityProcess.setId("");
+					workActivityProcess.setCount(0);
+					if (!"yes".equals(workScrap.getAct().getFlag())) {
+						workScrap.setStatus("3");
+						workActivityProcess.setIsApproval("2");
+					} else {
+						workActivityProcess.setIsApproval("1");
+					}
+					break;
+				}
+			}
+		} else {
+			workActivityMenu.setProcessType("workscrap");
+			for (int i = 0; i < workActivityProcesses.size(); i++) {
+				WorkActivityProcess activityProcess = workActivityProcesses.get(i);
+				String count = activityProcess.getCount() + "";
+				workActivityProcess = activityProcess;
+				if (!workActivityProcess.getIsApproval().equals("0")) {
+					workActivityProcess.setId("");
+				}
+				// 审核环节
+				if ("xzbzr".equals(taskDefKey) && count.contains("1")) {
+					taskCount = "1";
+					exp = "pass";
+					if ("yes".equals(workScrap.getAct().getFlag())) {
+						notifyRole = "审批完成";
+						workActivityProcess.setIsApproval("1");
+					} else {
+						notifyRole = "调整申请";
+						workActivityProcess.setIsApproval("2");
+					}
+					break;
+				} else if ("modifyApply".equals(taskDefKey)&& count.contains("0")) {
+					notifyRole = "行政部负责人审批";
+					taskCount = "0";
+					exp = "pass";
+					workActivityProcess.setCount(0);
+					enname = "xzbzr";
+					if (!"yes".equals(workScrap.getAct().getFlag())) {
+						workScrap.setStatus("3");
+					}
+					break;
+				} else if ("apply_end".equals(taskDefKey)) {
+				}
+
+			}
+		}
+		// 设置意见
+		workScrap.getAct().setComment(("yes".equals(workScrap.getAct().getFlag()) ? "[同意] " : "[驳回] ") + workScrap.getAct().getComment());
+		workScrap.preUpdate();
+		// 提交流程任务
+		vars.put(exp, "yes".equals(workScrap.getAct().getFlag()) ? true : false);
+		vars.put("passs", true);
+		workActivityProcessService.updateProcess(workActivityProcess,workActivityMenu,key,taskCount,workScrap.getProcessInstanceId(),taskDefKey,"modifyApply",workScrap.getAct().getFlag(),comment, activities);
+		// 提交流程任务
+		actTaskService.complete(workScrap.getAct().getTaskId(), workScrap.getAct().getProcInsId(), workScrap.getAct().getComment(), vars);
+		boolean state = actTaskService.isProcessEnd(workScrap.getAct().getProcInsId());
+		List<User> users = new ArrayList<>();
+		List<User> userList = new ArrayList<>();
+		if (!state) {
+			if(workScrap.getItem()!=null && workScrap.getItem().getWorkCatalogueItem()!=null){
+				title =  "物品名称:"+workScrap.getItem().getWorkCatalogueItem().getName();
+			}
+			if(workScrap.getItem()!=null){
+				str = "报废编码:"+workScrap.getNumber()+",固定资产编号:"+workScrap.getItem().getNumber()+",报废日期:"+ DateUtils.formatDate(workScrap.getScrapDate());
+			}
+			users.add(workScrap.getCreateBy());
+			if ("yes".equals(workScrap.getAct().getFlag())) {
+				workScrap.setStatus("5");
+				WorkProjectNotify notify = new WorkProjectNotify();
+				notify.setNotifyId(workScrap.getId());
+				userList = workProjectNotifyService.readByNotifyId(notify);
+				workProjectNotifyService
+						.save(UtilNotify
+								.saveNotify(workScrap.getId(),
+										workScrap.getCreateBy(),
+										workScrap.getCompanyId(),
+										title,
+										str,
+										"63",
+										"0",
+										"待通知",
+										notifyRole));
+
+			} else {
+				WorkProjectNotify notify = new WorkProjectNotify();
+				notify.setNotifyId(workScrap.getId());
+				userList = workProjectNotifyService.readByNotifyId(notify);
+				if (StringUtils.isNotBlank(workScrap.getStatus()) && !workScrap.getStatus().equals("3")){
+					workScrap.setStatus("4");
+					workProjectNotifyService
+							.save(UtilNotify
+									.saveNotify(workScrap.getId(),
+											workScrap.getCreateBy(),
+											workScrap.getCompanyId(),
+											title,
+											str,
+											"63",
+											"0",
+											"待通知",
+											notifyRole));
+				}
+			}
+			workActivityProcessService.deleteProcessIdAuditUsers(workScrap.getProcessInstanceId());
+		} else {
+			if (StringUtils.isNotBlank(workActivityMenu.getProcessType()) && !workActivityMenu.getProcessType().equals("workscrap")) {
+				WorkProjectNotify notify = new WorkProjectNotify();
+				notify.setNotifyId(workScrap.getId());
+				userList = workProjectNotifyService.readByNotifyId(notify);
+				//users.addAll(userList);
+				WorkProjectNotify workProjectNotify = UtilNotify
+						.saveNotify(workScrap.getId(),
+								new User(),
+								workScrap.getCompanyId(),
+								title,
+								str,
+								"63",
+								"0",
+								"待审批",
+								notifyRole);
+				List<WorkProjectNotify> workProjectNotifys = activityService.getByFlagAndTaskDefKeyList(
+						activities,
+						workProjectNotify,
+						taskDefKey,
+						workScrap.getAct().getFlag(),
+						taskCount,
+						workScrap.getCreateBy(),
+						workScrap.getOfficeId(),
+						"15");
+				for (WorkProjectNotify workProjectNotify1:workProjectNotifys){
+					users.add(workProjectNotify1.getUser());
+					workProjectNotify1.setId("");
+					workProjectNotify1.setIsNewRecord(false);
+					workProjectNotifyService
+							.save(workProjectNotify1);
+					if (!"modifyApply".equals(taskDefKey)){
+						Map<String,Object> extras = new HashMap<>();
+						extras.put("type","7001");
+						extras.put("id",workProjectNotify.getId());
+						extras.put("procDefKey","63");
+						UserUtils.pushInfoToApp(title,str,extras,workProjectNotify1.getUser().getId());
+
+					}
+				}
+				workActivityProcessService.deleteProcessIdAuditUsers(workScrap.getProcessInstanceId());
+			} else {
+				if (!"yes".equals(workScrap.getAct().getFlag())) {
+					WorkProjectNotify notify = new WorkProjectNotify();
+					notify.setNotifyId(workScrap.getId());
+					userList = workProjectNotifyService.readByNotifyId(notify);
+					//users.addAll(userList);
+					workProjectNotifyService
+							.save(UtilNotify
+									.saveNotify(workScrap.getId(),
+											workScrap.getCreateBy(),
+											workScrap.getCompanyId(),
+											title,
+											str,
+											"63",
+											"0",
+											"重新申请",
+											notifyRole));
+					users.add( workScrap.getCreateBy());
+				} else {
+					if (StringUtils.isNotBlank(enname)) {
+						WorkProjectNotify notify = new WorkProjectNotify();
+						notify.setNotifyId(workScrap.getId());
+						userList = workProjectNotifyService.readByNotifyId(notify);
+						WorkProjectNotify workProjectNotify = UtilNotify
+								.saveNotify(workScrap.getId(),
+										new User(),
+										workScrap.getCompanyId(),
+										title,
+										str,
+										"63",
+										"0",
+										"待审批",
+										notifyRole);
+						users.addAll(auditUsers);
+						for (User user1:auditUsers){
+							workProjectNotify.setId("");
+							workProjectNotify.setUser(user1);
+							workProjectNotify.setIsNewRecord(false);
+							workProjectNotifyService
+									.save(workProjectNotify);
+							if (!"modifyApply".equals(taskDefKey)){
+								Map<String,Object> extras = new HashMap<>();
+								extras.put("type","7001");
+								extras.put("id",workProjectNotify.getId());
+								extras.put("procDefKey","63");
+								UserUtils.pushInfoToApp(title,str,extras,user1.getId());
+							}
+						}
+					}else {
+						WorkProjectNotify notify = new WorkProjectNotify();
+						notify.setNotifyId(workScrap.getId());
+						userList = workProjectNotifyService.readByNotifyId(notify);
+						users.addAll(userList);
+						users.add(workScrap.getCreateBy());
+						workProjectNotifyService
+								.save(UtilNotify
+										.saveNotify(workScrap.getId(),
+												workScrap.getCreateBy(),
+												workScrap.getCompanyId(),
+												title,
+												str,
+												"63",
+												"0",
+												"重新申请",
+												notifyRole));
+					}
+				}
+			}
+		}
+		if (StringUtils.isNotBlank(title) && users!=null && users.size()!=0) {
+			for (User u : users) {
+				UserUtils.pushIm(u.getId(),title);
+			}
+		}
+		if (StringUtils.isNotBlank(title) && userList!=null && userList.size()!=0) {
+			for (User u : userList) {
+				UserUtils.pushMeIm(u.getId());
+			}
+		}
+
+		workScrapDao.update(workScrap);
+		if("5".equals(workScrap.getStatus())){
+			if(workScrap.getItem()!=null){
+				String iId = workScrap.getItem().getId();
+				if(StringUtils.isNotBlank(iId)){
+					WorkItem workItem = workItemService.get(iId);
+					//报废处理
+					workItem.setState("4");
+					workItemService.save(workItem);
+				}
+			}
+		}
+		return "保存审核意见成功!";
+	}
+
+	/**
+	 * 获取流程详细信息
+	 * @param processInstanceId
+	 */
+	@SuppressWarnings("unchecked")
+	public WorkScrap getByProcessInstanceId(String processInstanceId) {
+		WorkScrap workScrap = workScrapDao.getByProcessInstanceId(processInstanceId);
+		return workScrap;
+	}
+
+	/**
+	 * 强制撤销
+	 * @param
+	 */
+	@Transactional(readOnly = false)
+	public void cancelInvalidate(WorkScrap workScrap) {
+		String invalidateProcessInstanceId = workScrap.getProcessInstanceId();
+		try {
+			//将流程图中尚未走到的task的流程追踪信息逻辑删除,添加一条"撤销"流程追踪信息
+			WorkActivityProcess process = new WorkActivityProcess();
+			process.setProcessInstanceId(workScrap.getProcessInstanceId());
+			process.setIsApproval("0");
+			WorkActivityProcess workActivityProcess = new WorkActivityProcess();
+			workActivityProcess.setProcessInstanceId(workScrap.getProcessInstanceId());
+			List<WorkActivityProcess> processList = workActivityProcessService.findList(workActivityProcess);
+			WorkProjectNotify notify = new WorkProjectNotify();
+			notify.setNotifyId(workScrap.getId());
+			List<User> userList = workProjectNotifyService.readByNotifyId(notify);
+			if (userList!=null && userList.size()!=0) {
+				for (User u : userList) {
+					User user = UserUtils.get(u.getId());
+					/*List<WebSocket> toUserConns = ChatServerPool.getWebSocketByUser(u.getId());
+					for (WebSocket toUserConn : toUserConns) {
+						String message = "{\"to\":\""+u.getId()+"\"," +
+								"\"msg\":\"审批信息 物品报废申请人:"+ user.getName()+",报废编号:"+workScrap.getNumber()+" 强制撤销!\"," +
+								"\"useType\":\"sys\"}";
+						ChatServerPool.sendMessageToUser(toUserConn, message);//同时向本人发送消息
+					}*/
+					UserUtils.pushIm(u.getId(),"物品报废申请人:"+ user.getName()+",报废编号:"+workScrap.getNumber()+" 强制撤销!");
+				}
+			}
+			if(processList!=null && processList.size()>0){
+				for (int i =0;i<processList.size();i++) {
+					WorkActivityProcess p = processList.get(i);
+					if(StringUtils.isNotBlank(p.getIsApproval()) && "0".equals(p.getIsApproval())){
+						p.setDelFlag("1");
+						p.setIsApproval("-1");
+						workActivityProcessDao.updateDelFlagAndIsApproval(p);
+					}
+				}
+				WorkActivityProcess pro = new WorkActivityProcess();
+				pro.setId("");
+				pro.preInsert();
+				pro.setDelFlag("0");
+				pro.setRemarks("[强制撤销]");
+				pro.setProcessKey(processList.get(0).getProcessKey());
+				pro.setIsApproval("1");
+				pro.setProcessInstanceId(processList.get(0).getProcessInstanceId());
+				pro.setCount(0);
+				workActivityProcessDao.insert(pro);
+			}
+
+			//结束该流程,设为"撤销"状态
+			actTaskService.endProcessInstance(invalidateProcessInstanceId,"报废申请-强制撤销");
+			workScrap.setStatus("3");
+			workScrap.preUpdate();
+			workScrapDao.update(workScrap);
+
+		}catch (ActivitiObjectNotFoundException e){
+			System.err.println("撤销异常,因为这个流程已不存在!");
+			e.printStackTrace();
+		}
+		catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
+}

+ 446 - 0
src/main/java/com/jeeplus/modules/workscrap/web/WorkScrapController.java

@@ -0,0 +1,446 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workscrap.web;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.text.ParseException;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.validation.ConstraintViolationException;
+
+import com.google.common.base.Strings;
+import com.google.common.collect.Maps;
+import com.jeeplus.common.mapper.JsonMapper;
+import com.jeeplus.modules.act.entity.Act;
+import com.jeeplus.modules.act.service.ActTaskService;
+import com.jeeplus.modules.sys.entity.Office;
+import com.jeeplus.modules.sys.entity.User;
+import com.jeeplus.modules.sys.utils.DictUtils;
+import com.jeeplus.modules.sys.utils.UserUtils;
+import com.jeeplus.modules.workcatalogueitem.entity.WorkCatalogueItem;
+import com.jeeplus.modules.workcatalogueitem.service.WorkCatalogueItemService;
+import com.jeeplus.modules.workitem.service.WorkItemService;
+import org.activiti.engine.runtime.ProcessInstance;
+import org.activiti.engine.task.Task;
+import org.apache.commons.lang3.StringEscapeUtils;
+import org.apache.shiro.authz.annotation.Logical;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.servlet.mvc.support.RedirectAttributes;
+
+import com.jeeplus.modules.workitem.entity.WorkItem;
+import com.google.common.collect.Lists;
+import com.jeeplus.common.utils.DateUtils;
+import com.jeeplus.common.utils.MyBeanUtils;
+import com.jeeplus.common.config.Global;
+import com.jeeplus.common.persistence.Page;
+import com.jeeplus.common.web.BaseController;
+import com.jeeplus.common.utils.StringUtils;
+import com.jeeplus.common.utils.excel.ExportExcel;
+import com.jeeplus.common.utils.excel.ImportExcel;
+import com.jeeplus.modules.workscrap.entity.WorkScrap;
+import com.jeeplus.modules.workscrap.service.WorkScrapService;
+
+/**
+ * 报废管理Controller
+ * @author lw
+ * @version 2018-07-16
+ */
+@Controller
+@RequestMapping(value = "${adminPath}/workscrap/workScrap")
+public class WorkScrapController extends BaseController {
+
+	@Autowired
+	private WorkScrapService workScrapService;
+	@Autowired
+	private HttpServletRequest request;
+	@Autowired
+	private ActTaskService actTaskService;
+	@Autowired
+	private WorkItemService workItemService;
+	@Autowired
+	private WorkCatalogueItemService workCatalogueItemService;
+	@ModelAttribute
+	public WorkScrap get(@RequestParam(required=false) String id) {
+		WorkScrap entity = null;
+		if (StringUtils.isNotBlank(id)){
+			entity = workScrapService.get(id);
+		}
+		if (entity == null){
+			entity = new WorkScrap();
+		}
+		return entity;
+	}
+
+	/**
+	 * 报废管理列表页面
+	 */
+	@RequiresPermissions("workscrap:workScrap:list")
+	@RequestMapping(value = {"list", ""})
+	public String list(WorkScrap workScrap, HttpServletRequest request, HttpServletResponse response, Model model) {
+		Page<WorkScrap> page = workScrapService.findPage(new Page<WorkScrap>(request, response), workScrap);
+		model.addAttribute("page", page);
+		return "modules/workscrap/workScrapList";
+	}
+
+	/**
+	 * 查看,增加,编辑报废管理表单页面
+	 */
+	//@RequiresPermissions(value={"workscrap:workScrap:view","workscrap:workScrap:add","workscrap:workScrap:edit"},logical=Logical.OR)
+	@RequestMapping(value = "form")
+	public String form(WorkScrap workScrap, Model model) {
+		String view = "workScrapForm";
+		Office office = UserUtils.getSelectOffice();
+		String tabId = request.getParameter("tabId");
+		if("1".equals(tabId)){
+			view = "workScrapView";
+		}else if("3".equals(tabId)){
+			ProcessInstance processInstance = actTaskService.getProcIns(workScrap.getProcessInstanceId());
+			if (processInstance!=null) {
+				Task taskInfok = actTaskService.getCurrentTaskInfo(processInstance);
+				Act act = new Act();
+				act.setTaskId(taskInfok.getId());
+				act.setTaskName(taskInfok.getName());
+				act.setTaskDefKey(taskInfok.getTaskDefinitionKey());
+				act.setProcDefId(taskInfok.getProcessDefinitionId());
+				act.setProcInsId(taskInfok.getProcessInstanceId());
+				act.setTask(taskInfok);
+				workScrap.setAct(act);
+				view = "workScrapModify";
+				return "modules/workscrap/"+view;
+			}
+		}
+		// 环节编号
+		String taskDefKey = workScrap.getAct().getTaskDefKey();
+		if (StringUtils.isNotBlank(taskDefKey)){
+			view = "workScrapAudit";
+		}
+		if(StringUtils.isBlank(workScrap.getId())){
+			workScrap.setCreateBy(UserUtils.getUser());
+			workScrap.setScrapDate(new Date());
+			workScrap.setOfficeName(UserUtils.getSelectOffice().getTopCompany());
+		}
+		model.addAttribute("workScrap", workScrap);
+		return "modules/workscrap/"+view;
+	}
+	/**
+	 * 暂存
+	 */
+	@RequestMapping(value = "store")
+	public String store(WorkScrap workScrap,
+						Model model,
+						RedirectAttributes redirectAttributes) throws Exception{
+		if (!beanValidator(model, workScrap)){
+			return form(workScrap, model);
+		}
+		User user = workScrap.getCreateBy();
+		String submitter = "";
+		if(user != null){
+			submitter = user.getId();
+		}
+		String sta = workScrap.getStatus();
+		if(!UserUtils.getUser().getId().equals(submitter) && !Strings.isNullOrEmpty(submitter) && sta != null){
+			addMessage(redirectAttributes, "您不是申请人,无法修改");
+			return "redirect:"+Global.getAdminPath()+"/workscrap/workScrap/?repage";
+		}
+		workScrap.setStatus("1"); //暂存状态
+		workScrap.setCompanyId(UserUtils.getSelectCompany().getId());
+		workScrap.setOfficeId(UserUtils.getSelectOffice().getId());
+		if (StringUtils.isNotBlank(workScrap.getProcessInstanceId()) && workScrap.getProcessInstanceId().equals("NULL")){
+			workScrap.setProcessInstanceId("");
+		}
+		if(!workScrap.getIsNewRecord()){//编辑表单保存
+			WorkScrap t = workScrapService.get(workScrap.getId());//从数据库取出记录的值
+			MyBeanUtils.copyBeanNotNull2Bean(workScrap, t);//将编辑表单中的非NULL值覆盖数据库记录中的值
+			workScrapService.save(t);//保存
+		}else{//新增表单保存
+			workScrapService.save(workScrap);//保存
+		}
+		addMessage(redirectAttributes, "保存报废管理成功");
+		return "redirect:"+Global.getAdminPath()+"/workscrap/workScrap/?repage";
+	}
+	/**
+	 * 保存报废管理
+	 */
+	@RequiresPermissions(value={"workscrap:workScrap:add","workscrap:workScrap:edit"},logical=Logical.OR)
+	@RequestMapping(value = "save")
+	public String save(WorkScrap workScrap, Model model, RedirectAttributes redirectAttributes) throws Exception{
+		if (!beanValidator(model, workScrap)){
+			return form(workScrap, model);
+		}
+		User user = workScrap.getCreateBy();
+		String sta = workScrap.getStatus();
+		if(user!=null && !UserUtils.getUser().getId().equals(user.getId()) && StringUtils.isNotBlank(user.getId())){
+			addMessage(redirectAttributes, "您不是申请人,无法修改");
+			return "redirect:"+Global.getAdminPath()+"/workscrap/workScrap/?repage";
+		}
+		//状态设置为审核中
+		workScrap.setStatus("2");
+		String processInstanceId ="";
+		if (user!=null && StringUtils.isNotBlank(user.getId()) && StringUtils.isNotBlank(sta) && "3".equals(sta)){
+			processInstanceId = workScrapService.get(workScrap.getId()).getProcessInstanceId();
+		}
+		try {
+			Map<String, Object> variables = Maps.newHashMap();
+			workScrap.setCompanyId(UserUtils.getSelectCompany().getId());
+			workScrap.setOfficeId(UserUtils.getSelectOffice().getId());
+			String str = workScrapService.save(workScrap, variables,processInstanceId);
+			if (StringUtils.isNotBlank(str)){
+				addMessage(redirectAttributes, "报废申请提交失败:"+str);
+			}else {
+				addMessage(redirectAttributes, "报废申请已经提交");
+			}
+
+		} catch (Exception e) {
+			addMessage(redirectAttributes, "报废申请提交失败!");
+			addMessage(redirectAttributes, "系统内部错误");
+		}
+		return "redirect:"+Global.getAdminPath()+"/workscrap/workScrap/?repage";
+	}
+	/**
+	 * 工单执行(完成任务)
+	 * @param model
+	 * @return
+	 */
+	@RequestMapping(value = "saveAudit")
+	public String saveAudit(WorkScrap workScrap, Model model,
+							RedirectAttributes redirectAttributes) {
+		try {
+			List<User> users = UserUtils.getByProssType(workScrap.getProcessInstanceId(),1);
+			String flag = workScrap.getAct().getFlag();
+			if ("yes".equals(flag) && (users==null || users.size()==0)){
+				addMessage(redirectAttributes, "审批失败,审批人为空,请联系管理员!");
+			}else {
+				String str =workScrapService.auditSave(workScrap,users);
+				addMessage(redirectAttributes, str);
+			}
+		}catch (Exception e){
+			addMessage(redirectAttributes, "项目登记流程审批失败");
+		}
+
+		if (StringUtils.isNotBlank(workScrap.getHome()) && "home".equals(workScrap.getHome())){
+			return "redirect:" + Global.getAdminPath() + "/home/?repage";
+		}else {
+			return "redirect:"+Global.getAdminPath()+"/workscrap/workScrap/?repage";
+		}
+	}
+
+	/**
+	 * 强制撤销
+	 */
+	@RequestMapping("cancelInvalidate")
+	public String cancelInvalidate(WorkScrap workScrap,RedirectAttributes redirectAttributes){
+		workScrapService.cancelInvalidate(workScrap);
+		return "redirect:"+Global.getAdminPath()+"/workscrap/workScrap/?repage";
+	}
+	/**
+	 * 读取单个实体流程
+	 * @return
+	 */
+	@RequestMapping(value = "getProcessOne")
+	public String getProcessOne(WorkScrap workScrap,Model model) {
+		model.addAttribute("processInstanceId", workScrap.getProcessInstanceId());
+		return "modules/workscrap/workTrack";
+	}
+
+		/**
+         * 删除报废管理
+         */
+	@RequiresPermissions("workscrap:workScrap:del")
+	@RequestMapping(value = "delete")
+	public String delete(WorkScrap workScrap, RedirectAttributes redirectAttributes) {
+		workScrapService.delete(workScrap);
+		addMessage(redirectAttributes, "删除报废管理成功");
+		return "redirect:"+Global.getAdminPath()+"/workscrap/workScrap/?repage";
+	}
+
+	/**
+	 * 批量删除报废管理
+	 */
+	@RequiresPermissions("workscrap:workScrap:del")
+	@RequestMapping(value = "deleteAll")
+	public String deleteAll(String ids, RedirectAttributes redirectAttributes) {
+		String idArray[] =ids.split(",");
+		for(String id : idArray){
+			workScrapService.delete(workScrapService.get(id));
+		}
+		addMessage(redirectAttributes, "删除报废管理成功");
+		return "redirect:"+Global.getAdminPath()+"/workscrap/workScrap/?repage";
+	}
+
+	/**
+	 * 导出excel文件
+	 */
+	@RequiresPermissions("workscrap:workScrap:export")
+    @RequestMapping(value = "export", method=RequestMethod.POST)
+    public String exportFile(WorkScrap workScrap, HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) {
+		try {
+            String fileName = "报废管理"+DateUtils.getDate("yyyyMMddHHmmss")+".xlsx";
+            Page<WorkScrap> page = workScrapService.findPage(new Page<WorkScrap>(request, response, -1), workScrap);
+    		new ExportExcel("报废管理", WorkScrap.class).setDataList(page.getList()).write(response, fileName).dispose();
+    		return null;
+		} catch (Exception e) {
+			addMessage(redirectAttributes, "导出报废管理记录失败!失败信息:"+e.getMessage());
+		}
+		return "redirect:"+Global.getAdminPath()+"/workscrap/workScrap/?repage";
+    }
+
+	/**
+	 * 导入Excel数据
+
+	 */
+	@RequiresPermissions("workscrap:workScrap:import")
+    @RequestMapping(value = "import", method=RequestMethod.POST)
+    public String importFile(MultipartFile file, RedirectAttributes redirectAttributes) {
+		try {
+			int successNum = 0;
+			int failureNum = 0;
+			StringBuilder failureMsg = new StringBuilder();
+			ImportExcel ei = new ImportExcel(file, 1, 0);
+			List<WorkScrap> list = ei.getDataList(WorkScrap.class);
+			for (WorkScrap workScrap : list){
+				try{
+					workScrapService.save(workScrap);
+					successNum++;
+				}catch(ConstraintViolationException ex){
+					failureNum++;
+				}catch (Exception ex) {
+					failureNum++;
+				}
+			}
+			if (failureNum>0){
+				failureMsg.insert(0, ",失败 "+failureNum+" 条报废管理记录。");
+			}
+			addMessage(redirectAttributes, "已成功导入 "+successNum+" 条报废管理记录"+failureMsg);
+		} catch (Exception e) {
+			addMessage(redirectAttributes, "导入报废管理失败!失败信息:"+e.getMessage());
+		}
+		return "redirect:"+Global.getAdminPath()+"/workscrap/workScrap/?repage";
+    }
+
+	/**
+	 * 下载导入报废管理数据模板
+	 */
+	@RequiresPermissions("workscrap:workScrap:import")
+    @RequestMapping(value = "import/template")
+    public String importFileTemplate(HttpServletResponse response, RedirectAttributes redirectAttributes) {
+		try {
+            String fileName = "报废管理数据导入模板.xlsx";
+    		List<WorkScrap> list = Lists.newArrayList();
+    		new ExportExcel("报废管理数据", WorkScrap.class, 1).setDataList(list).write(response, fileName).dispose();
+    		return null;
+		} catch (Exception e) {
+			addMessage(redirectAttributes, "导入模板下载失败!失败信息:"+e.getMessage());
+		}
+		return "redirect:"+Global.getAdminPath()+"/workscrap/workScrap/?repage";
+    }
+
+
+	/**
+	 * 选择固定资产
+	 */
+	@RequestMapping(value = "selectitem")
+	public String selectitem(WorkItem item, String url, String fieldLabels, String fieldKeys, String searchLabel, String searchKey, HttpServletRequest request, HttpServletResponse response, Model model) {
+		item.setState("1");
+		item.setIsAssets("1");
+		Page<WorkItem> page = workItemService.findScrapPage(new Page<WorkItem>(request, response), item);
+		try {
+			fieldLabels = URLDecoder.decode(fieldLabels, "UTF-8");
+			fieldKeys = URLDecoder.decode(fieldKeys, "UTF-8");
+			searchLabel = URLDecoder.decode(searchLabel, "UTF-8");
+			searchKey = URLDecoder.decode(searchKey, "UTF-8");
+		} catch (UnsupportedEncodingException e) {
+			e.printStackTrace();
+		}
+		model.addAttribute("labelNames", fieldLabels.split("\\|"));
+		model.addAttribute("labelValues", fieldKeys.split("\\|"));
+		model.addAttribute("fieldLabels", fieldLabels);
+		model.addAttribute("fieldKeys", fieldKeys);
+		model.addAttribute("url", url);
+		model.addAttribute("searchLabel", searchLabel);
+		model.addAttribute("searchKey", searchKey);
+		model.addAttribute("obj", item);
+		model.addAttribute("page", page);
+		return "modules/sys/gridselectscrap";
+	}
+	/**
+	 * 选择物品
+	 */
+	@RequestMapping(value = "selectitems")
+	public String selectitems(WorkCatalogueItem workCatalogueItem, boolean isSingle,String url, String fieldLabels, String fieldKeys, String searchLabel, String searchKey, HttpServletRequest request, HttpServletResponse response, Model model) {
+		workCatalogueItem.setRemoveFlat("0");
+		Page<WorkCatalogueItem> page = workCatalogueItemService.findPage(new Page<WorkCatalogueItem>(request, response), workCatalogueItem);
+		try {
+			fieldLabels = URLDecoder.decode(fieldLabels, "UTF-8");
+			fieldKeys = URLDecoder.decode(fieldKeys, "UTF-8");
+			searchLabel = URLDecoder.decode(searchLabel, "UTF-8");
+			searchKey = URLDecoder.decode(searchKey, "UTF-8");
+		} catch (UnsupportedEncodingException e) {
+			e.printStackTrace();
+		}
+		model.addAttribute("labelNames", fieldLabels.split("\\|"));
+		model.addAttribute("labelValues", fieldKeys.split("\\|"));
+		model.addAttribute("fieldLabels", fieldLabels);
+		model.addAttribute("fieldKeys", fieldKeys);
+		model.addAttribute("url", url);
+		model.addAttribute("isSingle", isSingle);
+		model.addAttribute("searchLabel", searchLabel);
+		model.addAttribute("searchKey", searchKey);
+		model.addAttribute("obj", workCatalogueItem);
+		model.addAttribute("page", page);
+		return "modules/sys/gridselectstock";
+	}
+	//获取item
+	@RequestMapping(value = "getItem")
+	@ResponseBody
+	public String getPNumberr() {
+		HashMap<Object, Object> map = Maps.newHashMap();
+		String obj = request.getParameter("obj");
+		WorkItem workItem = workItemService.get(obj);
+		if(workItem!=null){
+			if(workItem.getWorkCatalogueItem()!=null){
+				String cItemId = workItem.getWorkCatalogueItem().getId();
+				if(StringUtils.isNotBlank(cItemId)){
+					WorkCatalogueItem workCatalogueItem = workCatalogueItemService.get(cItemId);
+					if(workCatalogueItem !=null){
+						map.put("cName",workCatalogueItem.getName());
+						map.put("cNumber",workCatalogueItem.getNumber());
+						map.put("cType",DictUtils.getMainDictLabel(workCatalogueItem.getType(),"item_type",""));
+						map.put("cModel",workCatalogueItem.getModel());
+						String s = StringEscapeUtils.unescapeHtml4(DictUtils.getMainDictLabel(workCatalogueItem.getPrimaryUnit(),"full_count_unit",""));
+						map.put("cPrimaryUnit",s);
+					}
+				}
+			}
+		}
+		return JsonMapper.toJsonString(map);
+	}
+
+	//获取item
+	@RequestMapping(value = "getItems")
+	@ResponseBody
+	public WorkCatalogueItem getPNumberrs(String id) throws ParseException {
+		WorkItem workItem = workItemService.get(id);
+		WorkCatalogueItem workCatalogueItem = new WorkCatalogueItem();
+		if(workItem!=null){
+			if(workItem.getWorkCatalogueItem()!=null){
+				String cItemId = workItem.getWorkCatalogueItem().getId();
+				if(StringUtils.isNotBlank(cItemId)){
+					 workCatalogueItem = workCatalogueItemService.get(cItemId);
+				}
+			}
+		}
+		return  workCatalogueItem;
+	}
+}

+ 52 - 0
src/main/java/com/jeeplus/modules/worksealform/dao/WorkSealFormDao.java

@@ -0,0 +1,52 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.worksealform.dao;
+
+import com.jeeplus.common.persistence.CrudDao;
+import com.jeeplus.common.persistence.annotation.MyBatisDao;
+import com.jeeplus.modules.worksealform.entity.WorkSealForm;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 用印申请DAO接口
+ * @author 丁旭
+ * @version 2017-04-26
+ */
+@MyBatisDao
+public interface WorkSealFormDao extends CrudDao<WorkSealForm> {
+
+    /**
+     * 更新流程实例ID
+     * @param workSealForm
+     * @return
+     */
+    public int updateProcessInstanceId(WorkSealForm workSealForm);
+
+    /**
+     * 获取当天出差list
+     * @param workSealForm
+     * @return
+     */
+    public List<WorkSealForm> findByCompany(WorkSealForm workSealForm);
+
+    /**
+     * 根据流程实例ID获取Leave
+     * @param processInstanceId
+     * @return
+     */
+    public WorkSealForm getByProcessInstanceId(String processInstanceId);
+
+    List getCreateDateList(Map<String, String> map);
+
+    List<WorkSealForm> findByCompany2(Map<String, Object> map);
+
+    public List getCreateDateList1(Map<String,String> map);
+    public List findByCompany1(Map<String,String> map);
+    public List getCreateDateListAll(Map<String,String> map);
+    public List findByCompanyAll(Map<String,String> map);
+    public List<WorkSealForm> findByManage(Map<String,Object> map);
+    public List<WorkSealForm> findByCompanySelf(Map<String,Object> map);
+}

+ 440 - 0
src/main/java/com/jeeplus/modules/worksealform/entity/WorkSealForm.java

@@ -0,0 +1,440 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.worksealform.entity;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.google.common.collect.Lists;
+import com.jeeplus.common.persistence.ActEntity;
+import com.jeeplus.common.utils.StringUtils;
+import com.jeeplus.common.utils.excel.annotation.ExcelField;
+import com.jeeplus.modules.sys.entity.Office;
+import com.jeeplus.modules.sys.entity.User;
+import com.jeeplus.modules.sys.entity.Workattachment;
+import org.activiti.engine.history.HistoricProcessInstance;
+import org.activiti.engine.repository.ProcessDefinition;
+import org.activiti.engine.runtime.ProcessInstance;
+import org.activiti.engine.task.Attachment;
+import org.activiti.engine.task.Task;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 用印申请Entity
+ * @author 丁旭
+ * @version 2017-04-26
+ */
+public class WorkSealForm extends ActEntity<WorkSealForm> {
+	
+	private static final long serialVersionUID = 1L;
+    private String processInstanceId; // 流程实例编号
+	private String documentName;		// 用印文件名称
+	private String documentCount;		// 文件个数
+	private String applicationDate;		// 申请时间
+	private String sealType;		// 印章分类
+	private User user;		// 经办人
+	private Office office;		// 用印部门
+	private String companyId;		// 申请公司
+    private String officeId;
+	private String status;		// 用印申请状态值
+    private String ids;
+    private Date createDateStart;
+    private Date createDateEnd;
+    private String reason;
+    private String files; //
+    private String idNames;
+    private String ida;
+    private String idNamea;
+    private String idb;
+    private String idNameb;
+    private String idc;
+    private String idNamec;
+    private String idd;
+    private String idNamed;
+    private String ide;
+    private String idNamee;
+    private String CCId;
+    private String name;
+    private String officeName;
+    private String time;
+    private List<String> adds = Lists.newArrayList();
+    private List<Workattachment> workAttachments = new ArrayList<Workattachment>();
+    private String home;
+
+    public String getOfficeName() {
+        return officeName;
+    }
+
+    public void setOfficeName(String officeName) {
+        this.officeName = officeName;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getTime() {
+        return time;
+    }
+
+    public void setTime(String time) {
+        this.time = time;
+    }
+
+    public String getFiles() {
+        return files;
+    }
+
+    public void setFiles(String files) {
+        this.files = files;
+    }
+
+	public WorkSealForm() {
+		super();
+	}
+
+	public WorkSealForm(String id){
+		super(id);
+	}
+
+    public String getReason() {
+        return reason;
+    }
+
+    public void setReason(String reason) {
+        this.reason = reason;
+    }
+
+    @ExcelField(title="用印文件名称", align=2, sort=6)
+	public String getDocumentName() {
+		return documentName;
+	}
+
+	public void setDocumentName(String documentName) {
+		this.documentName = documentName;
+	}
+	
+	@ExcelField(title="文件个数", align=2, sort=7)
+	public String getDocumentCount() {
+		return documentCount;
+	}
+
+	public void setDocumentCount(String documentCount) {
+		this.documentCount = documentCount;
+	}
+	
+	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+	@ExcelField(title="申请时间", align=2, sort=8)
+	public String getApplicationDate() {
+		return applicationDate;
+	}
+
+	public void setApplicationDate(String applicationDate) {
+		this.applicationDate = applicationDate;
+	}
+	
+	@ExcelField(title="印章分类", mainDictType="seal_type", align=2, sort=9)
+	public String getSealType() {
+		return sealType;
+	}
+
+	public void setSealType(String sealType) {
+		this.sealType = sealType;
+	}
+	
+	@ExcelField(title="经办人", fieldType=User.class, value="user.name", align=2, sort=10)
+	public User getUser() {
+		return user;
+	}
+
+	public void setUser(User user) {
+		this.user = user;
+	}
+	
+	@ExcelField(title="用印部门", fieldType=Office.class, value="office.name", align=2, sort=11)
+	public Office getOffice() {
+		return office;
+	}
+
+	public void setOffice(Office office) {
+		this.office = office;
+	}
+	
+	@ExcelField(title="申请公司", align=2, sort=12)
+	public String getCompanyId() {
+		return companyId;
+	}
+
+	public void setCompanyId(String companyId) {
+		this.companyId = companyId;
+	}
+	
+	@ExcelField(title="用印申请状态值", dictType="seal_status", align=2, sort=13)
+	public String getStatus() {
+		return status;
+	}
+
+	public void setStatus(String status) {
+		this.status = status;
+	}
+
+    private String comment; //审核意见 目前只保存手机端审核
+    private String leaveDetails;
+
+    public static long getSerialVersionUID() {
+        return serialVersionUID;
+    }
+
+    public String getLeaveDetails() {
+        return leaveDetails;
+    }
+
+    public void setLeaveDetails(String leaveDetails) {
+        this.leaveDetails = leaveDetails;
+    }
+
+    // -- 临时属性 --//
+    // 流程任务
+    private Task task;
+    private Map<String, Object> variables;
+    // 运行中的流程实例
+    private ProcessInstance processInstance;
+    // 历史的流程实例
+    private HistoricProcessInstance historicProcessInstance;
+    // 流程定义
+    private ProcessDefinition processDefinition;
+
+
+    public String getProcessInstanceId() {
+        return processInstanceId;
+    }
+
+    public void setProcessInstanceId(String processInstanceId) {
+        this.processInstanceId = processInstanceId;
+    }
+
+    public Task getTask() {
+        return task;
+    }
+
+    public void setTask(Task task) {
+        this.task = task;
+    }
+
+    public Map<String, Object> getVariables() {
+        return variables;
+    }
+
+    public void setVariables(Map<String, Object> variables) {
+        this.variables = variables;
+    }
+
+    public ProcessInstance getProcessInstance() {
+        return processInstance;
+    }
+
+    public void setProcessInstance(ProcessInstance processInstance) {
+        this.processInstance = processInstance;
+    }
+
+    public HistoricProcessInstance getHistoricProcessInstance() {
+        return historicProcessInstance;
+    }
+
+    public void setHistoricProcessInstance(HistoricProcessInstance historicProcessInstance) {
+        this.historicProcessInstance = historicProcessInstance;
+    }
+
+    public ProcessDefinition getProcessDefinition() {
+        return processDefinition;
+    }
+
+    public void setProcessDefinition(ProcessDefinition processDefinition) {
+        this.processDefinition = processDefinition;
+    }
+
+    public String getIds() {
+        List<String> idList = Lists.newArrayList();
+        if (StringUtils.isNotBlank(ids)) {
+            String ss = ids.trim().replace(" ", ",").replace(" ", ",").replace(",", ",").replace("'", "");
+            for (String s : ss.split(",")) {
+                // if(s.matches("\\d*")) {
+                idList.add("'" + s + "'");
+                // }
+            }
+        }
+        return StringUtils.join(idList, ",");
+    }
+
+    public void setIds(String ids) {
+        this.ids = ids;
+    }
+
+    public Date getCreateDateStart() {
+        return createDateStart;
+    }
+
+    public void setCreateDateStart(Date createDateStart) {
+        this.createDateStart = createDateStart;
+    }
+
+    public Date getCreateDateEnd() {
+        return createDateEnd;
+    }
+
+    public void setCreateDateEnd(Date createDateEnd) {
+        this.createDateEnd = createDateEnd;
+    }
+    public String getIdNames() {
+        List<String> idList = Lists.newArrayList();
+        if (StringUtils.isNotBlank(idNames)) {
+            String ss = idNames.trim().replace(" ", ",").replace(" ", ",").replace(",", ",").replace("'", "");
+            for (String s : ss.split(",")) {
+                // if(s.matches("\\d*")) {
+                idList.add("'" + s + "'");
+                // }
+            }
+        }
+        return StringUtils.join(idList, ",");
+    }
+
+    public void setIdNames(String idNames) {
+        this.idNames = idNames;
+    }
+
+    @ExcelField(title="申请人", align=2, sort=12)
+    public String getIda() {
+        return ida;
+    }
+
+    public void setIda(String ida) {
+        this.ida = ida;
+    }
+
+    public String getIdNamea() {
+        return idNamea;
+    }
+
+    public void setIdNamea(String idNamea) {
+        this.idNamea = idNamea;
+    }
+
+    public String getIdb() {
+        return idb;
+    }
+
+    public void setIdb(String idb) {
+        this.idb = idb;
+    }
+
+    public String getIdNameb() {
+        return idNameb;
+    }
+
+    public void setIdNameb(String idNameb) {
+        this.idNameb = idNameb;
+    }
+
+    public String getIdc() {
+        return idc;
+    }
+
+    public void setIdc(String idc) {
+        this.idc = idc;
+    }
+
+    public String getIdNamec() {
+        return idNamec;
+    }
+
+    public void setIdNamec(String idNamec) {
+        this.idNamec = idNamec;
+    }
+
+    public String getIdd() {
+        return idd;
+    }
+
+    public void setIdd(String idd) {
+        this.idd = idd;
+    }
+
+    public String getIdNamed() {
+        return idNamed;
+    }
+
+    public void setIdNamed(String idNamed) {
+        this.idNamed = idNamed;
+    }
+
+    public String getIde() {
+        return ide;
+    }
+
+    public void setIde(String ide) {
+        this.ide = ide;
+    }
+
+    public String getIdNamee() {
+        return idNamee;
+    }
+
+    public void setIdNamee(String idNamee) {
+        this.idNamee = idNamee;
+    }
+
+    public String getCCId() {
+        return CCId;
+    }
+
+    public void setCCId(String CCId) {
+        this.CCId = CCId;
+    }
+
+    public void setComment(String comment) {
+        this.comment = comment;
+    }
+
+    public String getComment() {
+        return comment;
+    }
+
+    public String getOfficeId() {
+        return officeId;
+    }
+
+    public void setOfficeId(String officeId) {
+        this.officeId = officeId;
+    }
+
+    public List<String> getAdds() {
+        return adds;
+    }
+
+    public void setAdds(List<String> adds) {
+        this.adds = adds;
+    }
+
+    public List<Workattachment> getWorkAttachments() {
+        return workAttachments;
+    }
+
+    public void setWorkAttachments(List<Workattachment> workAttachments) {
+        this.workAttachments = workAttachments;
+    }
+
+    public String getHome() {
+        return home;
+    }
+
+    public void setHome(String home) {
+        this.home = home;
+    }
+}

+ 832 - 0
src/main/java/com/jeeplus/modules/worksealform/service/WorkSealFormService.java

@@ -0,0 +1,832 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.worksealform.service;
+
+import com.google.common.collect.Maps;
+import com.jeeplus.common.persistence.Page;
+import com.jeeplus.common.service.CrudService;
+import com.jeeplus.common.utils.Collections3;
+import com.jeeplus.common.utils.JPushClientUtil;
+import com.jeeplus.common.utils.MenuStatusEnum;
+import com.jeeplus.common.utils.StringUtils;
+import com.jeeplus.modules.act.entity.Act;
+import com.jeeplus.modules.act.service.ActTaskService;
+import com.jeeplus.modules.act.utils.ActUtils;
+import com.jeeplus.modules.pushinfo.entity.Pushinfo;
+import com.jeeplus.modules.pushinfo.service.PushinfoService;
+import com.jeeplus.modules.sys.dao.UserDao;
+import com.jeeplus.modules.sys.entity.Office;
+import com.jeeplus.modules.sys.entity.User;
+import com.jeeplus.modules.sys.entity.Workattachment;
+import com.jeeplus.modules.sys.service.OfficeService;
+import com.jeeplus.modules.sys.service.WorkattachmentService;
+import com.jeeplus.modules.sys.utils.UserUtils;
+import com.jeeplus.modules.workapprovalcopy.entity.ApprovalCopy;
+import com.jeeplus.modules.workapprovalcopy.service.ApprovalCopyService;
+import com.jeeplus.modules.workprojectnotify.entity.WorkProjectNotify;
+import com.jeeplus.modules.workprojectnotify.service.WorkProjectNotifyService;
+import com.jeeplus.modules.worksealform.dao.WorkSealFormDao;
+import com.jeeplus.modules.worksealform.entity.WorkSealForm;
+import org.activiti.engine.*;
+import org.activiti.engine.history.HistoricProcessInstance;
+import org.activiti.engine.runtime.ProcessInstance;
+import org.activiti.engine.task.Task;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 用印申请Service
+ * @author 丁旭
+ * @version 2017-04-26
+ */
+@Service
+@Transactional(readOnly = true)
+public class WorkSealFormService extends CrudService<WorkSealFormDao, WorkSealForm> {
+
+    @Autowired
+    private WorkSealFormDao workSealFormDao;
+    @Autowired
+    private RuntimeService runtimeService;
+    @Autowired
+    protected TaskService taskService;
+    @Autowired
+    protected HistoryService historyService;
+    @Autowired
+    protected RepositoryService repositoryService;
+    @Autowired
+    private IdentityService identityService;
+    @Autowired
+    private UserDao userDao;
+    @Autowired
+    private ActTaskService actTaskService;
+
+    @Autowired
+    private ApprovalCopyService approvalCopyService;
+
+    @Autowired
+    private OfficeService officeService;
+
+    @Autowired
+    private PushinfoService pushinfoService;
+
+    @Autowired
+    private WorkProjectNotifyService workProjectNotifyService;
+    @Autowired
+    private WorkattachmentService workattachmentService;
+    /**
+     * 获取流程详细及工作流参数
+     * @param id
+     */
+    @SuppressWarnings("unchecked")
+    public WorkSealForm get(String id) {
+        WorkSealForm workSealForm = workSealFormDao.get(id);
+        List<Workattachment> Workattachments = workattachmentService.findAttachment(workSealForm.getId(),"68");
+        workSealForm.setWorkAttachments(Workattachments);
+        Map<String,Object> variables=null;
+        HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(workSealForm.getProcessInstanceId()).singleResult();
+        if(historicProcessInstance!=null) {
+            variables = Collections3.extractToMap(historyService.createHistoricVariableInstanceQuery().processInstanceId(historicProcessInstance.getId()).list(), "variableName", "value");
+        } else {
+            variables = runtimeService.getVariables(runtimeService.createProcessInstanceQuery().processInstanceId(workSealForm.getProcessInstanceId()).active().singleResult().getId());
+        }
+        workSealForm.setVariables(variables);
+        return workSealForm;
+    }
+
+    /**
+     * 获取流程详细及工作流参数
+     * @param id
+     */
+    @SuppressWarnings("unchecked")
+    public WorkSealForm getById(String id) {
+        WorkSealForm workSealForm = workSealFormDao.get(id);
+        return workSealForm;
+    }
+
+    @Transactional(readOnly = false)
+    public Map getUseSealById(String id,String type) {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        WorkSealForm workSealForm = this.getById(id);
+        Map<String,Object> map = Maps.newHashMap();
+        if(workSealForm!=null){
+            User user = userDao.get(workSealForm.getCreateBy());
+            String officeName = "";
+            if(user!=null){
+                map.put("userName", user.getName());
+                map.put("users", user.getId());
+                map.put("photo",user.getPhoto());
+                Office office = user.getOffice();
+                if(office!=null && office.getName()!=null){
+                    officeName = office.getName();
+                }
+            }
+            map.put("officeName",officeName);
+            map.put("createDate",workSealForm.getCreateDate()==null?"":sdf.format(workSealForm.getCreateDate()));
+            map.put("documentName",workSealForm.getDocumentName());
+            map.put("documentCount",workSealForm.getDocumentCount());
+            map.put("applicationDate",workSealForm.getApplicationDate());
+            String sealType = workSealForm.getSealType();
+            if (sealType.equals("1")){
+                sealType = "公章";
+            }else if (sealType.equals("2")){
+                sealType = "合同章";
+            }else if (sealType.equals("3")){
+                sealType = "法人章";
+            }else if (sealType.equals("4")){
+                sealType = "其他";
+            }
+            map.put("sealType",sealType);
+            map.put("status",workSealForm.getStatus());
+            String agentName = "";
+            if (workSealForm.getUser()!=null && workSealForm.getUser().getId()!=null){
+                User agentUser = UserUtils.get(workSealForm.getUser().getId());
+                if (agentUser!=null && agentUser.getName()!=null){
+                    agentName =agentUser.getName();
+                }
+            }
+            map.put("user",agentName);
+            String office = "";
+            if(workSealForm.getOffice()!=null && workSealForm.getOffice().getName()!=null){
+                office = workSealForm.getOffice().getName();
+            }
+            map.put("workSealOffice",office );
+            map.put("status",workSealForm.getStatus());
+            map.put("reason",workSealForm.getReason());
+            map.put("approvalId",id);
+            List<Workattachment> workattachmentList = workattachmentService.getListByAttachmentIdAndFlag(workSealForm.getId(),"68");
+            String files = "";
+            if (workattachmentList!=null && workattachmentList.size()!=0){
+                for (Workattachment workattachment : workattachmentList){
+                    files += workattachment.getUrl()+",";
+                }
+                if (files.length() > 1) {
+                    files = files.substring(0, files.length() - 1);
+                }
+            }
+            map.put("files", files);
+            List<Act> list = actTaskService.histoicFlowList(workSealForm.getProcessInstanceId(), "", "");
+            List<Act> list2 = actTaskService.toMyStartedList(workSealForm.getProcessInstanceId());
+            if (list2!=null && list2.size()!=0) {
+                Act act1 = list2.get(list2.size()-1);
+                map.put("taskId", act1.getTaskId());
+                map.put("taskName", act1.getTaskName());
+                map.put("procInsId", act1.getProcInsId());
+                map.put("procDefId", act1.getProcDefId());
+                map.put("actStatus", act1.getStatus()==null?"todo":act1.getStatus());
+                map.put("taskDefKey", act1.getTaskDefKey());
+                map.put("procDefKey", "sealform");
+            }
+            List list1 = new ArrayList();
+            String approvalStatus = "0";
+            String assigneeName = "";
+            if (list!=null && list.size()!=0) {
+                if (list.get(0).getHistIns().getActivityName().contains("审批")) {
+                    for (int i = list.size() - 1; i > -1; i--) {
+                        Act act = list.get(i);
+                        Map<String, Object> maps = new HashMap<String, Object>();
+                        String state = "0";
+                        String activityName = "";
+                        if (act.getHistIns().getActivityName().contains("审批")) {
+                            if (act.getDurationTime() != null && !act.getDurationTime().equals("")) {
+                                activityName = "已审批";
+                                if (UserUtils.getUser().getName().equals(act.getAssigneeName())){
+                                    approvalStatus = "1";
+                                }
+                            } else {
+                                activityName = "待审批";
+                                state = "2";
+                            }
+                        } else {
+                            activityName = act.getHistIns().getActivityName();
+                        }
+                        maps.put("activityName", activityName);
+                        maps.put("assigneeName", UserUtils.getUser().getName().equals(act.getAssigneeName()) ? "我" : act.getAssigneeName());
+                        maps.put("startTime", act.getHistIns().getStartTime() == null ? "" : sdf.format(act.getHistIns().getStartTime()));
+                        maps.put("endTime", act.getHistIns().getEndTime() == null ? "" : sdf.format(act.getHistIns().getEndTime()));
+                        maps.put("durationTime", act.getDurationTime());
+                        maps.put("state", state);
+                        maps.put("userId", act.getCurrentUser().getId());
+                        list1.add(maps);
+                    }
+                } else {
+                    if (workSealForm.getStatus().equals("4") || workSealForm.getStatus().equals("3")){
+                        for (int i = 0; i < list.size()-1; i++) {
+                            Act act = list.get(i);
+                            Map<String, Object> maps = new HashMap<String, Object>();
+                            String state = "0";
+                            String activityName = "";
+                            if (act.getHistIns().getActivityName().contains("发起申请")) {
+                                activityName = act.getHistIns().getActivityName();
+                                assigneeName = act.getAssigneeName();
+                            }else if (act.getHistIns().getActivityName().contains("审批")) {
+                                if (UserUtils.get(act.getHistIns().getAssignee())!=null) {
+                                    assigneeName = UserUtils.get(act.getHistIns().getAssignee()).getName();
+                                }
+                                if (act.getDurationTime() != null && !act.getDurationTime().equals("")) {
+                                    activityName = "已审批";
+                                    if (UserUtils.getUser().getName().equals(assigneeName)){
+                                        approvalStatus = "1";
+                                    }
+                                    if (i == (list.size()-2) && workSealForm.getStatus().equals("4")){
+                                        activityName = "审核驳回";
+                                        state = "1";
+                                    }else if (i == (list.size()-2) && workSealForm.getStatus().equals("3")){
+                                        activityName = "审核成功";
+                                    }
+                                } else {
+                                    activityName = "待审批";
+                                    state = "2";
+                                }
+                            }
+                            else {
+                                activityName = act.getHistIns().getActivityName();
+                                if (UserUtils.get(act.getHistIns().getAssignee())!=null) {
+                                    assigneeName = UserUtils.get(act.getHistIns().getAssignee()).getName();
+                                }
+                            }
+                            maps.put("activityName", activityName);
+                            maps.put("assigneeName", UserUtils.getUser().getName().equals(assigneeName) ? "我" : assigneeName);
+                            maps.put("startTime", act.getHistIns().getStartTime() == null ? "" : sdf.format(act.getHistIns().getStartTime()));
+                            maps.put("endTime", act.getHistIns().getEndTime() == null ? "" : sdf.format(act.getHistIns().getEndTime()));
+                            maps.put("durationTime", act.getDurationTime());
+                            maps.put("state", state);
+                            maps.put("userId", act.getCurrentUser().getId());
+                            list1.add(maps);
+                        }
+                    }else {
+                        for (int i = 0; i < list.size(); i++) {
+                            Act act = list.get(i);
+                            Map<String, Object> maps = new HashMap<String, Object>();
+                            String state = "0";
+                            String activityName = "";
+                            if (act.getHistIns().getActivityName().contains("发起申请")) {
+                                activityName = act.getHistIns().getActivityName();
+                                assigneeName = act.getAssigneeName();
+                            }else if (act.getHistIns().getActivityName().contains("审批")) {
+                                if (UserUtils.get(act.getHistIns().getAssignee())!=null) {
+                                    assigneeName = UserUtils.get(act.getHistIns().getAssignee()).getName();
+                                }
+                                if (act.getDurationTime() != null && !act.getDurationTime().equals("")) {
+                                    activityName = "已审批";
+                                    if (UserUtils.getUser().getName().equals(act.getAssigneeName())){
+                                        approvalStatus = "1";
+                                    }
+                                } else {
+                                    activityName = "待审批";
+                                    state = "2";
+                                }
+                            }
+                            else {
+                                activityName = act.getHistIns().getActivityName();
+                                if (UserUtils.get(act.getHistIns().getAssignee())!=null) {
+                                    assigneeName = UserUtils.get(act.getHistIns().getAssignee()).getName();
+                                }
+                            }
+                            if (workSealForm.getStatus().equals("5") && i == list.size() - 1) {
+                                activityName = "已撤销";
+                                state = "1";
+                            }
+                            maps.put("activityName", activityName);
+                            maps.put("assigneeName", UserUtils.getUser().getName().equals(assigneeName) ? "我" : assigneeName);
+                            maps.put("startTime", act.getHistIns().getStartTime() == null ? "" : sdf.format(act.getHistIns().getStartTime()));
+                            maps.put("endTime", act.getHistIns().getEndTime() == null ? "" : sdf.format(act.getHistIns().getEndTime()));
+                            maps.put("durationTime", act.getDurationTime());
+                            maps.put("state", state);
+                            maps.put("userId", act.getCurrentUser().getId());
+                            list1.add(maps);
+                        }
+                    }
+                }
+            }
+            map.put("approvalStatus", approvalStatus);
+            ApprovalCopy approvalCopy = new ApprovalCopy();
+            approvalCopy.setApprovalId(id);
+            List<ApprovalCopy> approvalCopyList = approvalCopyService.findList(approvalCopy);
+            String CCName = "";
+            String CCId = "";
+            Boolean readFlag = false;
+            if (approvalCopyList!=null && approvalCopyList.size()!=0) {
+                ApprovalCopy approvalCopy1 = approvalCopyList.get(0);
+                CCId = approvalCopy1.getCCId();
+                String[] CCid = approvalCopy1.getCCId().split(",");
+                readFlag = approvalCopy1.getReadFlag().equals("0");
+                if (type.equals("3") && readFlag){
+                    approvalCopy1.setReadFlag("1");
+                    approvalCopyService.save(approvalCopy1);
+                }
+                for (String userId : CCid) {
+                    User CCUser = UserUtils.get(userId);
+                    if (CCUser != null) {
+                        CCName = CCUser.getName() + ",";
+                    }
+                }
+                if (CCName.length() > 1) {
+                    CCName = CCName.substring(0, CCName.length() - 1);
+                } else {
+                    CCName = "";
+                }
+            }
+            map.put("nameCopy",CCName);
+            map.put("CCId",CCId);
+            map.put("process",list1);
+
+        }
+        return  map;
+    }
+
+    /**
+     * 获取流程详细信息
+     * @param processInstanceId
+     */
+    @SuppressWarnings("unchecked")
+    public WorkSealForm getByProcessInstanceId(String processInstanceId) {
+        WorkSealForm workSealForm = workSealFormDao.getByProcessInstanceId(processInstanceId);
+        return workSealForm;
+    }
+
+    @Transactional(readOnly = false)
+     public void delete(WorkSealForm workSealForm) {
+        workSealFormDao.delete(workSealForm);
+    }
+
+    @Transactional(readOnly = false)
+    public void update(WorkSealForm workSealForm) {
+        workSealFormDao.update(workSealForm);
+    }
+
+    /**
+     * 启动流程
+     * @param workSealForm
+     */
+    @Transactional(readOnly = false)
+    public void save(WorkSealForm workSealForm, Map<String, Object> variables,String type) {
+        // 保存业务数据
+        if (StringUtils.isBlank(workSealForm.getId())) {
+            // 保存业务数据
+            workSealForm.preInsert();
+            workSealFormDao.insert(workSealForm);
+            logger.debug("save entity: {}", workSealForm);
+
+            // 用来设置启动流程的人员ID,引擎会自动把用户ID保存到activiti:initiator中
+            identityService.setAuthenticatedUserId(workSealForm.getCurrentUser().getId());
+
+            // 启动流程
+            String businessKey = workSealForm.getId().toString();
+            variables.put("type", "sealform");
+            variables.put("busId", businessKey);
+            variables.put("title", workSealForm.getReason());//设置标题;
+            ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(ActUtils.PD_SEALFORM[0], businessKey, variables);
+
+            // 更新流程实例ID
+            workSealForm.setProcessInstanceId(processInstance.getId());
+            workSealForm.setProcessInstance(processInstance);
+            workSealFormDao.updateProcessInstanceId(workSealForm);
+
+            logger.debug("start process of {key={}, bkey={}, pid={}, variables={}}", new Object[] {
+                    ActUtils.PD_SEALFORM[0], businessKey, processInstance.getId(), variables });
+        }else{
+            workSealForm.preUpdate();
+            workSealFormDao.update(workSealForm);
+            workSealForm.getAct().setComment(("yes".equals(workSealForm.getAct().getFlag())?"[重申] ":"[销毁] ")+workSealForm.getAct().getComment());
+
+            // 完成流程任务
+            Map<String, Object> vars = Maps.newHashMap();
+            vars.put("reApply", "yes".equals(workSealForm.getAct().getFlag())? true : false);
+            actTaskService.complete(workSealForm.getAct().getTaskId(), workSealForm.getAct().getProcInsId(), workSealForm.getAct().getComment(), workSealForm.getComment(), vars);
+        }
+
+    }
+
+
+    /**
+     * 查询待办任务
+     * @param userId 用户ID
+     * @return
+     */
+    public List<WorkSealForm> findTodoTasks(String userId) {
+
+        List<WorkSealForm> results = new ArrayList<WorkSealForm>();
+        List<Task> tasks = new ArrayList<Task>();
+        // 根据当前人的ID查询
+        List<Task> todoList = taskService.createTaskQuery().processDefinitionKey(ActUtils.PD_SEALFORM[0]).taskAssignee(userId).active().orderByTaskPriority().desc().orderByTaskCreateTime().desc().list();
+        // PD_SEALFORM
+        List<Task> unsignedTasks = taskService.createTaskQuery().processDefinitionKey(ActUtils.PD_SEALFORM[0]).taskCandidateUser(userId).active().orderByTaskPriority().desc().orderByTaskCreateTime().desc().list();
+        // 合并
+        tasks.addAll(todoList);
+        tasks.addAll(unsignedTasks);
+        // 根据流程的业务ID查询实体并关联
+        for (Task task : tasks) {
+            String processInstanceId = task.getProcessInstanceId();
+            ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).active().singleResult();
+            String businessKey = processInstance.getBusinessKey();
+            WorkSealForm workSealForm = workSealFormDao.get(businessKey);
+            workSealForm.setTask(task);
+            workSealForm.setProcessInstance(processInstance);
+            workSealForm.setProcessDefinition(repositoryService.createProcessDefinitionQuery().processDefinitionId((processInstance.getProcessDefinitionId())).singleResult());
+            results.add(workSealForm);
+        }
+        return results;
+    }
+
+    @Transactional(readOnly = false)
+    public void saveFile(WorkSealForm workSealForm) {
+        if (StringUtils.isBlank(workSealForm.getId())){
+            workSealForm.preInsert();
+            workSealFormDao.insert(workSealForm);
+        }else{
+            workSealForm.preUpdate();
+            workSealFormDao.update(workSealForm);
+        }
+    }
+
+    public Page<WorkSealForm> find(Page<WorkSealForm> page, WorkSealForm workSealForm) {
+
+        workSealForm.getSqlMap().put("dsf", dataScopeFilter(workSealForm.getCurrentUser(), "o", "u","", MenuStatusEnum.WORK_SEAL_FORM.getValue()));
+
+        workSealForm.setPage(page);
+
+        page.setList(workSealFormDao.findList(workSealForm));
+
+        for(WorkSealForm item : page.getList()) {
+            String processInstanceId = item.getProcessInstanceId();
+            HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
+            if(historicProcessInstance!=null) {
+                item.setHistoricProcessInstance(historicProcessInstance);
+                item.setProcessDefinition(repositoryService.createProcessDefinitionQuery().processDefinitionId(historicProcessInstance.getProcessDefinitionId()).singleResult());
+            } else {
+                ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).active().singleResult();
+                if (processInstance != null){
+                    item.setProcessInstance(processInstance);
+                    item.setProcessDefinition(repositoryService.createProcessDefinitionQuery().processDefinitionId(processInstance.getProcessDefinitionId()).singleResult());
+                }
+            }
+            ProcessInstance processInstance = actTaskService.getProcIns(item.getProcessInstanceId());
+            if (processInstance!=null) {
+                Task taskInfok = actTaskService.getCurrentTaskInfo(processInstance);
+                if (StringUtils.isNotBlank(taskInfok.getAssignee()) && taskInfok.getAssignee().equals(UserUtils.getUser().getId())) {
+                    item.setTask(taskInfok);
+                }
+            }
+        }
+        return page;
+    }
+
+    /* * 审核审批保存
+     * @param testAudit
+     */
+    @Transactional(readOnly = false)
+    public void auditSave(WorkSealForm workSealForm) {
+
+        // 设置意见
+        workSealForm.getAct().setComment(("yes".equals(workSealForm.getAct().getFlag())?"[同意] ":"[驳回] ")+workSealForm.getAct().getComment());
+        workSealForm.preUpdate();
+        this.update(workSealForm);
+        // 对不同环节的业务逻辑进行操作
+        String taskDefKey = workSealForm.getAct().getTaskDefKey();
+
+        //发送通知
+        WorkProjectNotify notify = new WorkProjectNotify();
+        notify.setNotifyId(workSealForm.getId());
+        notify.setCompanyId(UserUtils.getSelectCompany().getId());
+        notify.setType("27");
+        notify.setStatus("0");
+        notify.setNotifyRole("");
+
+        //业务逻辑对应的条件表达式
+        String exp = "";
+        // 审核环节
+        if ("audit1".equals(taskDefKey)){
+            exp = "pass";
+        }else if ("audit2".equals(taskDefKey)){
+            exp = "pass";
+        }else if ("audit3".equals(taskDefKey)){
+            exp = "pass";
+        }else if ("audit4".equals(taskDefKey)){
+            exp = "pass";
+        }else if ("audit5".equals(taskDefKey)){
+            exp = "pass";
+        }else if("apply_end".equals(taskDefKey)){
+            exp = "pass";
+        }
+        // 未知环节,直接返回
+        else{
+            return;
+        }
+
+        // 提交流程任务
+        Map<String, Object> vars = Maps.newHashMap();
+        vars.put(exp, "yes".equals(workSealForm.getAct().getFlag())? false : true);
+        // 提交流程任务
+        actTaskService.complete(workSealForm.getAct().getTaskId(), workSealForm.getAct().getProcInsId(), workSealForm.getAct().getComment(), vars);
+        boolean state = actTaskService.isProcessEnd(workSealForm.getAct().getProcInsId());
+        workSealForm.setStatus("2");
+        if (!state){
+            if ("yes".equals(workSealForm.getAct().getFlag())){
+                workSealForm.setStatus("3");
+            }else {
+                workSealForm.setStatus("4");
+            }
+        }
+        workSealForm.preUpdate();
+        this.update(workSealForm);
+
+        //需在workSealForm更新后 操作:
+        //1待审核  2审核中 3通过 4驳回 5已撤销 6催办中
+        if("2".equals(workSealForm.getStatus())){
+            workSealForm = this.get(workSealForm.getId());
+            String userId = workSealForm.getVariables().get("assignee").toString();
+            if(StringUtils.isNotBlank(userId)){
+                notify.setUser(UserUtils.get(userId));
+            }
+            notify.setTitle("您有新的用印申请待审批");
+            notify.setRemarks("待审批");
+            notify.setContent("用印申请--待审批");
+
+        }else if("3".equals(workSealForm.getStatus())){
+            notify.setUser(workSealForm.getCreateBy());
+            notify.setTitle("您的用印申请已通过");
+            notify.setRemarks("待通知");
+            notify.setContent(workSealForm.getAct().getComment());
+        }else if("4".equals(workSealForm.getStatus())){
+            notify.setUser(workSealForm.getCreateBy());
+            notify.setTitle("您的用印申请被驳回");
+            notify.setRemarks("待通知");
+            notify.setContent(workSealForm.getAct().getComment());
+        }
+        workProjectNotifyService.save(notify);
+
+        //更新审核人的阅读状态
+        WorkProjectNotify notify2 = new WorkProjectNotify();
+        notify2.setUser(UserUtils.getUser());
+        notify2.setNotifyId(workSealForm.getId());
+        workProjectNotifyService.readByNotifyIdAndNotifyUser(notify2);
+
+        //经办人
+        if("3".equals(workSealForm.getStatus()) || "4".equals(workSealForm.getStatus())){
+            if(workSealForm.getUser()!=null && StringUtils.isNotBlank(workSealForm.getUser().getId())){
+                String jingbanUser = workSealForm.getUser().getId();
+                WorkProjectNotify notify3 = new WorkProjectNotify();
+                notify3.setNotifyId(workSealForm.getId());
+                notify3.setCompanyId(UserUtils.getSelectCompany().getId());
+                notify3.setType("27");
+                notify3.setStatus("0");
+                notify3.setNotifyRole("");
+                notify3.setUser(workSealForm.getUser());
+                notify3.setRemarks("待通知");
+                if("3".equals(workSealForm.getStatus())){
+                    notify3.setTitle(UserUtils.get(workSealForm.getCreateBy().getId()).getName()+"的用印申请已通过");
+                    notify3.setContent(UserUtils.get(workSealForm.getCreateBy().getId()).getName()+"的用印申请已通过");
+                }
+                if("4".equals(workSealForm.getStatus())){
+                    notify3.setTitle(UserUtils.get(workSealForm.getCreateBy().getId()).getName()+"的用印申请被驳回");
+                    notify3.setContent(UserUtils.get(workSealForm.getCreateBy().getId()).getName()+"的用印申请被驳回");
+                }
+                workProjectNotifyService.save(notify3);
+            }
+        }
+
+        //抄送
+        if("3".equals(workSealForm.getStatus()) || "4".equals(workSealForm.getStatus())){
+            ApprovalCopy approvalCopy = approvalCopyService.getByApprovalId(workSealForm.getId());
+            if(approvalCopy!=null && StringUtils.isNotBlank(approvalCopy.getCCId())){
+                WorkProjectNotify notify1= new WorkProjectNotify();
+                notify1.setNotifyId(workSealForm.getId());
+                notify1.setCompanyId(UserUtils.getSelectCompany().getId());
+                notify1.setType("27");
+                notify1.setStatus("0");
+                notify1.setNotifyRole("");
+                notify1.setContent(workSealForm.getAct().getComment());
+                String[] ccIds = approvalCopy.getCCId().split(",");
+                for(String ccId : ccIds){
+                    if(StringUtils.isNotBlank(ccId)){
+                        notify1.setUser(new User(ccId));
+                        if("3".equals(workSealForm.getStatus())){
+                            notify1.setTitle(UserUtils.get(workSealForm.getCreateBy().getId()).getName()+"的用印申请已通过");
+                        }
+                        if("4".equals(workSealForm.getStatus())){
+                            notify1.setTitle(UserUtils.get(workSealForm.getCreateBy().getId()).getName()+"的用印申请被驳回");
+                        }
+                        notify1.setRemarks("待通知");
+                        notify1.setId("");
+                        workProjectNotifyService.save(notify1);
+                    }
+                }
+            }
+        }
+    }
+
+    /* * 审核审批保存
+     * @param testAudit
+     */
+    @Transactional(readOnly = false)
+    public boolean saveWorkSealForm(WorkSealForm workSealForm) {
+        try {
+            workSealForm.setStatus("1");
+            String approverId = "";
+            List<String> adds = workSealForm.getAdds();
+            for(int i = 0;i<adds.size();i++){
+                if(i + 1 == adds.size()){
+                    approverId += adds.get(i);
+                }else{
+                    approverId += adds.get(i) + ",";
+                }
+            }
+            workSealForm.setIds(approverId);
+            Map<String, Object> variables = Maps.newHashMap();
+            String type = "1";
+            String alias = "1";
+            List<String> assigneeList=new ArrayList<String>(); //分配任务的人员
+            if(!UserUtils.getUser().isAdmin() && approverId!=null && !approverId.equals("")) {
+                if (approverId.contains(UserUtils.getUser().getId())){
+                    logger.error("用印申请失败,审批人不能为本人");
+                    return false;
+                }
+                String[] approverIds = approverId.split(",");
+                for (int i =0 ;i<approverIds.length;i++){
+                    assigneeList.add(approverIds[i]);
+                }
+                type = approverIds.length+"";
+                alias = approverIds[0];
+            }
+            variables.put("assigneeList", assigneeList);
+            variables.put("count",assigneeList.size());
+            User agent = workSealForm.getUser();//经办人
+            Office office = workSealForm.getOffice();//用印部门
+            //approver.setId(approverId);
+            User CC = new User();
+            CC.setId(workSealForm.getCCId());
+            User user = UserUtils.getUser();
+
+            workSealForm.setUser(agent);
+            workSealForm.setOffice(office);
+            //workSealForm.setUser(user);
+            workSealForm.setOffice(office);
+            workSealForm.setCreateBy(user);
+            workSealForm.setUpdateBy(user);
+            workSealForm.setDelFlag("0");
+            workSealForm.setStatus("1");
+            workSealForm.setCompanyId(UserUtils.getSelectCompany()==null?"":UserUtils.getSelectCompany().getId());
+            workSealForm.setOfficeId(UserUtils.getSelectOffice()==null?"":UserUtils.getSelectOffice().getId());
+            save(workSealForm,variables,type);
+            ApprovalCopy approvalCopy = new ApprovalCopy();
+            approvalCopy.setCCId(workSealForm.getCCId());
+            approvalCopy.setUserId(user.getId());
+            approvalCopy.setType("sealform");
+            approvalCopy.setRemarks(workSealForm.getReason());
+            approvalCopy.setApprovalId(workSealForm.getId());
+            approvalCopy.setApproverId(approverId);
+            approvalCopy.setReadFlag("0");
+            approvalCopyService.save(approvalCopy);
+
+            //给抄送人、审批人发送通知
+            if(approvalCopy!=null && org.apache.commons.lang3.StringUtils.isNotBlank(approvalCopy.getId())){
+                String chaosongIds = approvalCopy.getCCId();//给所有抄送人发送通知
+                String shenpiIds = alias;//给审批流程的第一个人发送通知
+                this.sendNotify(chaosongIds,shenpiIds,approvalCopy.getApprovalId());
+                String content = "审批信息 申请人:" + user.getName() + ",用印申请: 待审批!";
+                UserUtils.pushIm(alias,content);
+            }
+
+            String title="审批";
+            String content =  UserUtils.getUser().getName()+"的用印申请需要你审批";
+            String status = "待审批";
+            Office office1 = workSealForm.getOffice();
+            String officeName = "";
+            if (office1!=null){
+                Office o = officeService.get(office1.getId());
+                officeName = o.getName();
+            }
+            String agentName = "";
+            if (agent!=null && agent.getName()!=null){
+                agentName =agent.getName();
+            }
+            String remakers = "用印部门:"+officeName+ "\n"
+                    +"经办人:"+agentName+ "\n"
+                    +"日期:"+workSealForm.getApplicationDate();
+            Map extras = new HashMap();
+            extras.put("type", "4001");
+            extras.put("id", workSealForm.getId());
+            extras.put("procDefKey", "sealform");
+
+            boolean b = JPushClientUtil.sendNotificationToAlias(title, content, extras, alias);
+            Pushinfo pushinfo = new Pushinfo();
+            pushinfo.setCurrentUser(UserUtils.getUser());
+            pushinfo.setRemarks(remakers);
+            pushinfo.setUserId(UserUtils.getUser().getId());
+            pushinfo.setType("4001");
+            pushinfo.setPushId(workSealForm.getId());
+            pushinfo.setTitle(title);
+            pushinfo.setContent(content);
+            pushinfo.setPushUserId(alias);
+            pushinfo.setParentType("singleApproval");
+            pushinfo.setStatus(status);
+            pushinfo.setCompanyId(UserUtils.getSelectCompany()==null?"":UserUtils.getSelectCompany().getId());
+            pushinfo.setAddcontent("sealform");
+            pushinfo.setMobile("ios,android");
+            pushinfoService.save(pushinfo);
+            if (b){
+                return true;
+            }
+        } catch (Exception e) {
+            logger.error("启动用印流程失败:", e);
+        }
+        return false;
+    }
+
+    @Transactional(readOnly = false)
+    public void sendNotify(String chaosongIds,String shenpiId,String sealFormId) {
+        if(StringUtils.isNotBlank(sealFormId)){
+            if(StringUtils.isNotBlank(chaosongIds)){
+                WorkProjectNotify notify = new WorkProjectNotify();
+                notify.setTitle(UserUtils.getUser().getName()+"发起了用印申请");
+                notify.setRemarks("待通知");
+                notify.setContent(UserUtils.getUser().getName()+"的用印申请");
+                notify.setNotifyRole("");
+                notify.setNotifyId(sealFormId);
+                notify.setStatus("0");
+                notify.setCompanyId(UserUtils.getSelectCompany().getId());
+                notify.setType("27");
+                String[] arr = chaosongIds.split(",");
+                for (String id : arr){
+                    if(StringUtils.isNotBlank(id)){
+                        notify.setId("");
+                        notify.setUser(new User(id));
+                        workProjectNotifyService.save(notify);
+                    }
+                }
+            }
+            if(StringUtils.isNotBlank(shenpiId)){
+                WorkProjectNotify notify = new WorkProjectNotify();
+                notify.setTitle("您有新的用印申请待审批");
+                notify.setRemarks("待审批");
+                notify.setContent("用印申请--待审批");
+                notify.setNotifyRole("");
+                notify.setUser(new User(shenpiId));
+                notify.setNotifyId(sealFormId);
+                notify.setStatus("0");
+                notify.setCompanyId(UserUtils.getSelectCompany().getId());
+                notify.setType("27");
+                workProjectNotifyService.save(notify);
+            }
+        }
+    }
+
+
+
+    public List getCreateDateList(String companyId, String date) {
+        Map<String,String> map = new HashMap<String, String>();
+        map.put("companyId",companyId);
+        map.put("date",date);
+        return workSealFormDao.getCreateDateList(map);
+    }
+
+    public List<WorkSealForm> findByCompany2(WorkSealForm workSealForm, String date) {
+        Map<String,Object> map = new HashMap<>();
+        map.put("seal",workSealForm);
+        map.put("date",date);
+        return workSealFormDao.findByCompany2(map);
+    }
+
+    public List getCreateDateList1(String time) {
+        Map<String,String> map = new HashMap<String,String>();
+        map.put("userId",UserUtils.getUser().getId());
+        map.put("time",time);
+        return workSealFormDao.getCreateDateList1(map);
+    }
+    public List<WorkSealForm> findByCompany1(String time){
+        Map<String,String> map = new HashMap<String,String>();
+        map.put("userId",UserUtils.getUser().getId());
+        map.put("time",time);
+        return workSealFormDao.findByCompany1(map);
+    }
+
+    public List getCreateDateListAll(String time) {
+        Map<String,String> map = new HashMap<String,String>();
+        WorkSealForm w =new WorkSealForm();
+        map.put("sqlStr",dataScopeFilter(w.getCurrentUser(), "o", "u", "s", MenuStatusEnum.WORK_SEAL_FORM.getValue()));
+        map.put("time",time);
+        return workSealFormDao.getCreateDateListAll(map);
+    }
+    public List<WorkSealForm> findByCompanyAll(String time){
+        Map<String,String> map = new HashMap<String,String>();
+        WorkSealForm w =new WorkSealForm();
+        map.put("sqlStr",dataScopeFilter(w.getCurrentUser(), "o", "u", "s", MenuStatusEnum.WORK_SEAL_FORM.getValue()));
+        map.put("time",time);
+        return workSealFormDao.findByCompanyAll(map);
+    }
+
+    public List<WorkSealForm> findByManage(Map<String,Object> map) {
+        return workSealFormDao.findByManage(map);
+    }
+    public List<WorkSealForm> findByCompanySelf(Map<String,Object> map) {
+        return workSealFormDao.findByCompanySelf(map);
+    }
+}

+ 355 - 0
src/main/java/com/jeeplus/modules/worksealform/web/WorkSealFormController.java

@@ -0,0 +1,355 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.worksealform.web;
+
+import com.jeeplus.common.config.Global;
+import com.jeeplus.common.json.AjaxJson;
+import com.jeeplus.common.persistence.Page;
+import com.jeeplus.common.utils.MyBeanUtils;
+import com.jeeplus.common.utils.StringUtils;
+import com.jeeplus.common.web.BaseController;
+import com.jeeplus.modules.act.entity.Act;
+import com.jeeplus.modules.act.service.ActAuditService;
+import com.jeeplus.modules.act.service.ActTaskService;
+import com.jeeplus.modules.act.utils.ActUtils;
+import com.jeeplus.modules.sys.entity.Office;
+import com.jeeplus.modules.sys.entity.User;
+import com.jeeplus.modules.sys.entity.Workattachment;
+import com.jeeplus.modules.sys.service.OfficeService;
+import com.jeeplus.modules.sys.service.WorkattachmentService;
+import com.jeeplus.modules.sys.utils.UserUtils;
+import com.jeeplus.modules.workclientinfo.entity.WorkClientAttachment;
+import com.jeeplus.modules.workprojectnotify.entity.WorkProjectNotify;
+import com.jeeplus.modules.workprojectnotify.service.WorkProjectNotifyService;
+import com.jeeplus.modules.worksealform.entity.WorkSealForm;
+import com.jeeplus.modules.worksealform.service.WorkSealFormService;
+import org.activiti.engine.RuntimeService;
+import org.activiti.engine.TaskService;
+import org.apache.shiro.authz.annotation.Logical;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.servlet.mvc.support.RedirectAttributes;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 用印申请Controller
+ * @author 丁旭
+ * @version 2017-04-26
+ */
+@Controller
+@RequestMapping(value = "${adminPath}/worksealform/workSealForm")
+public class WorkSealFormController extends BaseController {
+
+	@Autowired
+	private WorkSealFormService workSealFormService;
+
+	private Logger logger = LoggerFactory.getLogger(getClass());
+
+	@Autowired
+	protected RuntimeService runtimeService;
+
+	@Autowired
+	protected TaskService taskService;
+
+	@Autowired
+	private ActTaskService actTaskService;
+	@Autowired
+	private ActAuditService actAuditService;
+
+	@Autowired
+	private OfficeService officeService;
+	@Autowired
+	private WorkProjectNotifyService workProjectNotifyService;
+	@Autowired
+	private WorkattachmentService workattachmentService;
+
+	private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+	@ModelAttribute
+	public WorkSealForm get(@RequestParam(required=false) String id) {
+		WorkSealForm entity = null;
+		if (StringUtils.isNotBlank(id)){
+			entity = workSealFormService.get(id);
+		}
+		if (entity == null){
+			entity = new WorkSealForm();
+		}
+		return entity;
+	}
+
+	@RequiresPermissions(value={"worksealform:workSealForm:view","worksealform:workSealForm:add","worksealform:workSealForm:edit"},logical= Logical.OR)
+	@RequestMapping(value = {"form"})
+	public String form(WorkSealForm workSealForm, Model model) {
+		String view = "workSealFormForm";
+		// 查看审批申请单
+		if (org.apache.commons.lang3.StringUtils.isNotBlank(workSealForm.getId())){//.getAct().getProcInsId())){
+			// 环节编号
+			String taskDefKey = workSealForm.getAct().getTaskDefKey();
+			if (taskDefKey!=null) {
+				// 查看工单
+				if (workSealForm.getAct().isFinishTask()) {
+					view = "workSealFormView";
+				}
+				// 修改环节
+				else if ("apply_end".equals(taskDefKey)) {
+					view = "workSealFormAudit";
+				}
+				// 审核环节
+				else if ("audit1".equals(taskDefKey)) {
+					if (org.apache.commons.lang3.StringUtils.isBlank(workSealForm.getAct().getStatus())){
+						model.addAttribute("disabled","true");
+					}else {
+						model.addAttribute("disabled","false");
+					}
+					view = "workSealFormAudit";
+				}
+				//
+				else if ("modifyApply".equals(taskDefKey)) {
+					view = "workSealFormForm";
+				}
+			}
+			if (org.apache.commons.lang3.StringUtils.isNotBlank(workSealForm.getName())){
+				if (workSealForm.getName().equals("view")){
+					model.addAttribute("disabled","true");
+					workSealForm.getAct().setProcInsId(workSealForm.getProcessInstanceId());
+					view = "workSealFormAudit";
+				}
+			}
+		}
+
+
+		model.addAttribute("workSealForm", workSealForm);
+		return "modules/worksealform/"+view;
+	}
+
+	/**
+	 * 启动请假流程
+	 * @param workSealForm
+	 */
+	@RequestMapping(value = "save", method = RequestMethod.POST)
+	public String save(WorkSealForm workSealForm, Model model, RedirectAttributes redirectAttributes) throws Exception{
+		if (!beanValidator(model, workSealForm)){
+			return form(workSealForm, model);
+		}
+		if (org.apache.commons.lang3.StringUtils.isNotBlank(workSealForm.getId())) {
+			WorkSealForm t = workSealFormService.get(workSealForm.getId());//从数据库取出记录的值
+			MyBeanUtils.copyBeanNotNull2Bean(workSealForm, t);//将编辑表单中的非NULL值覆盖数据库记录中的值
+			if (t.getStatus().equals("3") || t.getStatus().equals("4")){
+				addMessage(redirectAttributes, "已结束流程不能修改!");
+			}else {
+				workSealFormService.save(t);
+			}
+		} else {
+			try {
+				boolean b = workSealFormService.saveWorkSealForm(workSealForm);
+				if (b){
+					addMessage(redirectAttributes, "用印申请已经提交");
+				}else {
+					addMessage(redirectAttributes, "系统内部错误!");
+				}
+			}catch (Exception e){
+				logger.info("save e.getMessage()="+e.getMessage());
+				addMessage(redirectAttributes, "系统内部错误!");
+			}
+		}
+		if (workSealForm.getWorkAttachments()!=null && workSealForm.getWorkAttachments().size()!=0){
+			List<Workattachment> list = workSealForm.getWorkAttachments();
+			for (Workattachment w:list){
+				if (StringUtils.isNotBlank(w.getUrl()) && !w.getUrl().equals("null")) {
+					w.setCompanyId(workSealForm.getCompanyId());
+					w.setAttachmentUser(UserUtils.getUser().getId());
+					w.setAttachmentId(workSealForm.getId());
+					w.setId("");
+					workattachmentService.save(w);
+				}
+			}
+		}
+		return "redirect:"+ Global.getAdminPath()+"/worksealform/workSealForm/?repage";
+	}
+
+
+	/**
+	 * 工单执行(完成任务)
+	 * @param workSealForm
+	 * @param model
+	 * @return
+	 */
+	@RequestMapping(value = "saveAudit")
+	public String saveAudit(WorkSealForm workSealForm, Map<String, Object> vars, Model model, RedirectAttributes redirectAttributes) {
+		/*if (org.apache.commons.lang3.StringUtils.isBlank(workSealForm.getAct().getComment())){
+			addMessage(model, "请填写审核意见。");
+			return form(workSealForm, model);
+		}*/
+		//workSealFormService.auditSave(workSealForm);
+		Act act = workSealForm.getAct();
+		AjaxJson json = actAuditService.saveAudit(act, act.getProcInsId(), "sealform", workSealForm.getAct().getComment(), workSealForm.getId(), "2");
+		addMessage(redirectAttributes, json.getMsg());
+		if (workSealForm!=null && org.apache.commons.lang3.StringUtils.isNotBlank(workSealForm.getHome()) && workSealForm.getHome().equals("home")){
+			return "redirect:" + adminPath + "/home";
+		}
+		return "redirect:" + adminPath + "/worksealform/workSealForm";
+	}
+
+	/**
+	 * 读取所有流程
+	 * @return
+	 */
+	@RequiresPermissions("worksealform:workSealForm:list")
+	@RequestMapping(value = {"list", ""})
+	public String list(WorkSealForm workSealForm, HttpServletRequest request, HttpServletResponse response, Model model) {
+		User user = UserUtils.getUser();
+		if (!user.isAdmin()){
+			workSealForm.setCompanyId(user.getComId());
+			if (!UserUtils.isManager()){
+				workSealForm.setCreateBy(user);
+			}
+		}
+		Page<WorkSealForm> page = workSealFormService.find(new Page<WorkSealForm>(request, response), workSealForm);
+		model.addAttribute("page", page);
+		return "modules/worksealform/workSealFormList";
+	}
+
+	/**
+	 * 待办任务列表页面
+	 * @param request
+	 * @param response
+	 * @param model
+	 * @return
+	 */
+	@RequestMapping(value = {"workSealFormTodoList"})
+	public String oaEvectionTodoList(Act act, HttpServletRequest request, HttpServletResponse response, Model model) {
+		act.setProcDefKey("sealform");
+		List<Act> list = actTaskService.todoList(act);
+		Office office = UserUtils.getSelectCompany();
+		String companyId = office==null?"":office.getId();
+		List<WorkSealForm> lists = new ArrayList<WorkSealForm>();
+		for (Act a : list) {
+			WorkSealForm workSealForm = workSealFormService.getByProcessInstanceId(a.getProcInsId());
+			if (workSealForm != null && workSealForm.getCompanyId().equals(companyId)) {
+				if (a.getVars().getMap().get("applyUserId")!=null) {
+					User user = UserUtils.get(a.getVars().getMap().get("applyUserId").toString());
+					if (user != null) {
+						a.getVars().getMap().put("applyUserId", UserUtils.get(a.getVars().getMap().get("applyUserId").toString()).getName());
+					}
+				}
+				workSealForm.setAct(a);
+				if (com.jeeplus.common.utils.StringUtils.isNotBlank(workSealForm.getId())){
+					workSealForm.setName(officeService.get(companyId).getName());
+				}
+				lists.add(workSealForm);
+			}
+		}
+		model.addAttribute("list", lists);
+		return "modules/worksealform/workSealFormTodoList";
+	}
+
+	/**
+	 * 已办任务
+	 * @param act
+	 * @param request
+	 * @param response
+	 * @param model
+	 * @return
+	 */
+	@RequestMapping(value = {"workSealFormHistoricList"})
+	public String oaEvectionHistoricList (Act act, HttpServletRequest request, HttpServletResponse response, Model model){
+		act.setProcDefKey("sealform");
+		Page<Act> page = actTaskService.historicList(new Page<Act>(request, response), act);
+		List<Act> list = page.getList();
+		Office office = UserUtils.getSelectCompany();
+		String companyId = office==null?"":office.getId();
+		List<WorkSealForm> lists = new ArrayList<WorkSealForm>();
+		for (Act a : list) {
+			WorkSealForm workSealForm = workSealFormService.getByProcessInstanceId(a.getHistTask().getProcessInstanceId());
+			if (workSealForm != null && workSealForm.getCompanyId().equals(companyId)) {
+				if (a.getVars().getMap().get("applyUserId")!=null){
+					a.getVars().getMap().put("applyUserId",UserUtils.get(a.getVars().getMap().get("applyUserId").toString()).getName());
+				}
+				workSealForm.setAct(a);
+				if (com.jeeplus.common.utils.StringUtils.isNotBlank(workSealForm.getId())){
+					workSealForm.setName(officeService.get(companyId).getName());
+				}
+				lists.add(workSealForm);
+			}
+		}
+		model.addAttribute("list", lists);
+
+		return "modules/worksealform/workSealFormHistoricList";
+	}
+
+	/**
+	 * 审核企业信息
+	 * @param response
+	 * @param model
+	 * @return
+	 */
+	@RequestMapping(value = "applyOnSealForm")
+	public String applyOnCompany(Act act, HttpServletResponse response, Model model) {
+		// 获取流程XML上的表单KEY
+		String formKey = actTaskService.getFormKey(act.getProcDefId(), act.getTaskDefKey());
+		//logger.info("------formKeys:"+formKeys);
+		// 获取流程实例对象
+		if (act.getProcInsId() != null){
+			if(actTaskService.getProcIns(act.getProcInsId())!=null){
+				act.setProcIns(actTaskService.getProcIns(act.getProcInsId()));
+			}else{
+				act.setFinishedProcIns(actTaskService.getFinishedProcIns(act.getProcInsId()));
+			}
+		}
+		return "redirect:" + ActUtils.getFormUrl(formKey, act);
+	}
+
+	/**
+	 * 用印申请撤销
+	 * @param
+	 * @return
+	 */
+	@RequestMapping(value = "revoke")
+	public String revoke(HttpServletRequest request, HttpServletResponse response) {
+
+		HashMap<String, String> requestMap = findRequestMap(request);
+		String processInstanceId = requestMap.get("processInstanceId");
+		String id = requestMap.get("id");
+		String deleteReason = requestMap.get("reason");
+
+		AjaxJson j = new AjaxJson();
+		try {
+			WorkSealForm workSealForm = workSealFormService.getById(id);
+			workSealForm.setStatus("5");
+			workSealForm.preUpdate();
+			workSealFormService.update(workSealForm);
+			Map map = workSealFormService.getUseSealById(id,"1");
+			j.put("data",map);
+			actTaskService.endProcessInstance(processInstanceId, deleteReason);
+			j.setMsg("撤销申请成功");
+
+			//撤销后,更改所有发送过的通知的阅读状态
+			WorkProjectNotify notify = new WorkProjectNotify();
+			notify.setNotifyId(workSealForm.getId());
+			workProjectNotifyService.readByNotifyId(notify);
+		}catch (Exception e){
+			j.setErrorCode("101");
+			logger.info(e.getMessage());
+			j.setMsg("撤销申请失败");
+			j.setSuccess(false);
+		}
+		return "redirect:" + adminPath + "/worksealform/workSealForm";
+	}
+
+}

+ 32 - 0
src/main/java/com/jeeplus/modules/worksendmessage/dao/WorkSendMessageDao.java

@@ -0,0 +1,32 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.worksendmessage.dao;
+
+import com.jeeplus.common.persistence.CrudDao;
+import com.jeeplus.common.persistence.annotation.MyBatisDao;
+import com.jeeplus.modules.sys.entity.Office;
+import com.jeeplus.modules.sys.entity.User;
+import com.jeeplus.modules.worksendmessage.entity.WorkSendMessage;
+
+import java.util.List;
+
+/**
+ * 发文管理DAO接口
+ * @author ssrh
+ * @version 2018-07-12
+ */
+@MyBatisDao
+public interface WorkSendMessageDao extends CrudDao<WorkSendMessage> {
+
+
+    void updateProcessIdAndStatus(WorkSendMessage workSendMessage);
+
+    List<Office> queryOfficeLists(WorkSendMessage workSendMessage);
+
+    List<User> queryUserLists(WorkSendMessage workSendMessage);
+
+    List<WorkSendMessage> queryMemberPage(WorkSendMessage workSendMessage);
+
+    void updateStatusById(WorkSendMessage workSendMessage);
+}

+ 13 - 0
src/main/java/com/jeeplus/modules/worksendmessage/dao/WorkSendMessageDetailDao.java

@@ -0,0 +1,13 @@
+package com.jeeplus.modules.worksendmessage.dao;
+
+import com.jeeplus.common.persistence.annotation.MyBatisDao;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.Map;
+
+@MyBatisDao
+public interface WorkSendMessageDetailDao {
+    public void batchInsert(Map map);
+
+    public void deleteHandlers(@Param("messageId") String messageId, @Param("flag")int flag);
+}

+ 186 - 0
src/main/java/com/jeeplus/modules/worksendmessage/entity/WorkSendMessage.java

@@ -0,0 +1,186 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.worksendmessage.entity;
+
+import java.util.Date;
+import java.util.List;
+
+import com.google.common.collect.Lists;
+import com.jeeplus.common.persistence.ActEntity;
+import com.jeeplus.modules.sys.entity.Office;
+
+import com.jeeplus.common.persistence.DataEntity;
+import com.jeeplus.common.utils.excel.annotation.ExcelField;
+import com.jeeplus.modules.sys.entity.User;
+import com.jeeplus.modules.workclientinfo.entity.WorkClientAttachment;
+
+/**
+ * 发文管理Entity
+ * @author ssrh
+ * @version 2018-07-12
+ */
+public class WorkSendMessage extends ActEntity<WorkSendMessage> {
+	
+	private static final long serialVersionUID = 1L;
+    public static final String ATTACHMENT_TYPE = "107";
+    private String title;		// 发文标题
+	private String num;		// 发文文号
+	private String docType;		// 发文类型
+	private String person;		// 拟  稿  人
+	private String summary;		// 发文摘要
+	private Office office;		// 部门ID
+	private Office company;		// 公司ID
+	private Date beginCreateDate;		// 开始 发文日期
+	private Date endCreateDate;		// 结束 发文日期
+    private List<WorkClientAttachment> workAttachments = Lists.newArrayList();
+    private List<User> userList;
+    private List<Office> officeList;
+    private Integer state;
+    private String processInstanceId;
+    private String home;
+
+	public WorkSendMessage() {
+		super();
+	}
+
+	public WorkSendMessage(String id){
+		super(id);
+	}
+
+	@ExcelField(title="发文标题", align=2, sort=7)
+	public String getTitle() {
+		return title;
+	}
+
+	public void setTitle(String title) {
+		this.title = title;
+	}
+	
+	@ExcelField(title="发文文号", align=2, sort=8)
+	public String getNum() {
+		return num;
+	}
+
+	public void setNum(String num) {
+		this.num = num;
+	}
+	
+	@ExcelField(title="发文类型", align=2, sort=9)
+	public String getDocType() {
+		return docType;
+	}
+
+	public void setDocType(String docType) {
+		this.docType = docType;
+	}
+	
+	@ExcelField(title="拟  稿  人", align=2, sort=10)
+	public String getPerson() {
+		return person;
+	}
+
+	public void setPerson(String person) {
+		this.person = person;
+	}
+	
+	@ExcelField(title="发文摘要", align=2, sort=11)
+	public String getSummary() {
+		return summary;
+	}
+
+	public void setSummary(String summary) {
+		this.summary = summary;
+	}
+	
+	@ExcelField(title="部门ID", align=2, sort=12)
+	public Office getOffice() {
+		return office;
+	}
+
+	public void setOffice(Office office) {
+		this.office = office;
+	}
+	
+	@ExcelField(title="公司ID", align=2, sort=13)
+	public Office getCompany() {
+		return company;
+	}
+
+	public void setCompany(Office company) {
+		this.company = company;
+	}
+	
+	public Date getBeginCreateDate() {
+		return beginCreateDate;
+	}
+
+	public void setBeginCreateDate(Date beginCreateDate) {
+		this.beginCreateDate = beginCreateDate;
+	}
+	
+	public Date getEndCreateDate() {
+		return endCreateDate;
+	}
+
+	public void setEndCreateDate(Date endCreateDate) {
+		this.endCreateDate = endCreateDate;
+	}
+
+    public List<WorkClientAttachment> getWorkAttachments() {
+        return workAttachments;
+    }
+
+    public void setWorkAttachments(List<WorkClientAttachment> workAttachments) {
+        this.workAttachments = workAttachments;
+    }
+
+    public List<User> getUserList() {
+        return userList;
+    }
+
+    public void setUserList(List<User> userList) {
+        this.userList = userList;
+    }
+
+    public List<Office> getOfficeList() {
+        return officeList;
+    }
+
+    public void setOfficeList(List<Office> officeList) {
+        this.officeList = officeList;
+    }
+
+    public Integer getState() {
+        return state;
+    }
+
+    public void setState(Integer state) {
+        this.state = state;
+    }
+
+    public String getProcessInstanceId() {
+        return processInstanceId;
+    }
+
+    public void setProcessInstanceId(String processInstanceId) {
+        this.processInstanceId = processInstanceId;
+    }
+
+    public static String getBizeCode(String docType) {
+	    switch (docType){
+            case "1":
+                return "15";
+            default:
+                return "15";
+        }
+    }
+
+    public String getHome() {
+        return home;
+    }
+
+    public void setHome(String home) {
+        this.home = home;
+    }
+}

+ 734 - 0
src/main/java/com/jeeplus/modules/worksendmessage/service/WorkSendMessageService.java

@@ -0,0 +1,734 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.worksendmessage.service;
+
+import java.util.*;
+
+import com.google.common.collect.Maps;
+import com.jeeplus.common.utils.DateUtils;
+import com.jeeplus.common.utils.MenuStatusEnum;
+import com.jeeplus.common.utils.StringUtils;
+import com.jeeplus.modules.act.service.ActTaskService;
+import com.jeeplus.modules.projectrecord.enums.ProjectStatusEnum;
+import com.jeeplus.modules.serialnum.service.SerialNumTplService;
+import com.jeeplus.modules.sys.dao.UserDao;
+import com.jeeplus.modules.sys.entity.Office;
+import com.jeeplus.modules.sys.entity.User;
+import com.jeeplus.modules.sys.utils.DictUtils;
+import com.jeeplus.modules.sys.utils.UserUtils;
+import com.jeeplus.modules.workactivity.dao.WorkActivityProcessDao;
+import com.jeeplus.modules.workactivity.entity.Activity;
+import com.jeeplus.modules.workactivity.entity.WorkActivityProcess;
+import com.jeeplus.modules.workactivity.service.ActivityService;
+import com.jeeplus.modules.workactivity.service.WorkActivityProcessService;
+import com.jeeplus.modules.workactivitymenu.entity.WorkActivityMenu;
+import com.jeeplus.modules.workactivitymenu.service.WorkActivityMenuService;
+import com.jeeplus.modules.workclientinfo.dao.WorkClientAttachmentDao;
+import com.jeeplus.modules.workclientinfo.entity.WorkClientAttachment;
+import com.jeeplus.modules.workprojectnotify.entity.WorkProjectNotify;
+import com.jeeplus.modules.workprojectnotify.service.WorkProjectNotifyService;
+import com.jeeplus.modules.workprojectnotify.util.UtilNotify;
+import com.jeeplus.modules.worksendmessage.dao.WorkSendMessageDetailDao;
+import org.activiti.engine.ActivitiObjectNotFoundException;
+import org.activiti.engine.HistoryService;
+import org.activiti.engine.IdentityService;
+import org.activiti.engine.RuntimeService;
+import org.activiti.engine.runtime.ProcessInstance;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.jeeplus.common.persistence.Page;
+import com.jeeplus.common.service.CrudService;
+import com.jeeplus.modules.worksendmessage.entity.WorkSendMessage;
+import com.jeeplus.modules.worksendmessage.dao.WorkSendMessageDao;
+
+/**
+ * 发文管理Service
+ * @author ssrh
+ * @version 2018-07-12
+ */
+@Service
+@Transactional(readOnly = true)
+public class WorkSendMessageService extends CrudService<WorkSendMessageDao, WorkSendMessage> {
+
+    @Autowired
+    private WorkClientAttachmentDao workClientAttachmentDao;
+    @Autowired
+    private UserDao userDao;
+    @Autowired
+    private WorkProjectNotifyService workProjectNotifyService;
+    @Autowired
+    private IdentityService identityService;
+    @Autowired
+    private ActTaskService actTaskService;
+    @Autowired
+    private WorkActivityMenuService workActivityMenuService;
+    @Autowired
+    private RuntimeService runtimeService;
+    @Autowired
+    private WorkActivityProcessService workActivityProcessService;
+    @Autowired
+    private ActivityService activityService;
+    @Autowired
+    protected HistoryService historyService;
+    @Autowired
+    private WorkActivityProcessDao workActivityProcessDao;
+    @Autowired
+    private SerialNumTplService serialNumTplService;
+    @Autowired
+    private WorkSendMessageDetailDao workSendMessageDetailDao;
+
+	public WorkSendMessage get(String id) {
+        WorkSendMessage workSendMessage = super.get(id);
+        return workSendMessage;
+	}
+
+    public void queryDetails(WorkSendMessage workSendMessage) {
+        if(workSendMessage!=null&& StringUtils.isNotBlank(workSendMessage.getId())){
+            WorkClientAttachment attchment = new WorkClientAttachment();
+            attchment.setAttachmentId(workSendMessage.getId());
+            workSendMessage.setWorkAttachments(workClientAttachmentDao.findList(attchment));
+            workSendMessage.setOfficeList(this.queryOfficeLists(workSendMessage));
+            workSendMessage.setUserList(this.queryUserLists(workSendMessage));
+        }
+    }
+
+    private List<User> queryUserLists(WorkSendMessage workSendMessage) {
+        return dao.queryUserLists(workSendMessage);
+    }
+
+    private List<Office> queryOfficeLists(WorkSendMessage workSendMessage) {
+        return dao.queryOfficeLists(workSendMessage);
+    }
+
+    public List<WorkSendMessage> findList(WorkSendMessage workSendMessage) {
+        if(!UserUtils.getUser().isAdmin()) {
+            String dataScopeSql = dataScopeFilter(workSendMessage.getCurrentUser(), "o", "u", "s", MenuStatusEnum.WORK_SENDMESSAGE.getValue());
+            workSendMessage.getSqlMap().put("dsf", dataScopeSql);
+        }
+		return super.findList(workSendMessage);
+	}
+	
+	public Page<WorkSendMessage> findPage(Page<WorkSendMessage> page, WorkSendMessage workSendMessage) {
+        if(!UserUtils.getUser().isAdmin()) {
+            String dataScopeSql = dataScopeFilter(workSendMessage.getCurrentUser(), "o", "u", "s", MenuStatusEnum.WORK_SENDMESSAGE.getValue());
+            workSendMessage.getSqlMap().put("dsf", dataScopeSql);
+        }
+		return super.findPage(page, workSendMessage);
+	}
+	
+	@Transactional(readOnly = false)
+	public void save(WorkSendMessage workSendMessage) {
+        preSave(workSendMessage);
+		super.save(workSendMessage);
+		saveAttachments(workSendMessage);
+		saveUserList(workSendMessage);
+		saveOfficeList(workSendMessage);
+	}
+
+    private void saveOfficeList(WorkSendMessage workSendMessage) {
+        List<Office> officeList = workSendMessage.getOfficeList();
+        if(officeList ==null|| officeList.size()<=0){
+            return;
+        }
+        workSendMessageDetailDao.deleteHandlers(workSendMessage.getId(),1);
+        Iterator<Office> iterator = officeList.iterator();
+        while (iterator.hasNext()){
+            Office next = iterator.next();
+            if (next==null||StringUtils.isBlank(next.getId())){
+                iterator.remove();
+            }
+        }
+        if(officeList ==null|| officeList.size()<=0){
+            return;
+        }
+        HashMap<String, Object> map = new HashMap<>(5);
+        map.put("messageId", workSendMessage.getId());
+        map.put("handlerList", officeList);
+        map.put("flag", 1);
+        workSendMessageDetailDao.batchInsert(map);
+    }
+
+    private void saveUserList(WorkSendMessage workSendMessage) {
+        List<User> userList = workSendMessage.getUserList();
+        if(userList ==null|| userList.size()<=0){
+            return;
+        }
+        workSendMessageDetailDao.deleteHandlers(workSendMessage.getId(),0);
+        Iterator<User> iterator = userList.iterator();
+        while (iterator.hasNext()){
+            User next = iterator.next();
+            if (next==null||StringUtils.isBlank(next.getId())){
+                iterator.remove();
+            }
+        }
+        if(userList ==null|| userList.size()<=0){
+            return;
+        }
+        HashMap<String, Object> map = new HashMap<>(5);
+        map.put("messageId", workSendMessage.getId());
+        map.put("handlerList", userList);
+        map.put("flag", 0);
+        workSendMessageDetailDao.batchInsert(map);
+    }
+
+    private void preSave(WorkSendMessage workSendMessage) {
+        if(workSendMessage.getOffice()==null){
+            workSendMessage.setOffice(UserUtils.getSelectOffice());
+}
+        if(workSendMessage.getCompany()==null){
+	        workSendMessage.setCompany(UserUtils.getSelectCompany());
+        }
+        if(StringUtils.isBlank(workSendMessage.getNum())){
+            String serialNum = serialNumTplService.genSerialNum(workSendMessage.getCompany(), WorkSendMessage.getBizeCode(workSendMessage.getDocType()));
+            workSendMessage.setNum(serialNum);
+        }
+    }
+
+    private void saveAttachments(WorkSendMessage workSendMessage) {
+        for (WorkClientAttachment workClientAttachment : workSendMessage.getWorkAttachments()) {
+            if (workClientAttachment.getId() == null) {
+                continue;
+            }
+            if (WorkClientAttachment.DEL_FLAG_NORMAL.equals(workClientAttachment.getDelFlag())) {
+                workClientAttachment.setAttachmentId(workSendMessage.getId());
+                workClientAttachment.setAttachmentFlag(WorkSendMessage.ATTACHMENT_TYPE);
+                workClientAttachment.setAttachmentUser(UserUtils.getUser().getId());
+                if (StringUtils.isBlank(workClientAttachment.getId()) || "null".equals(workClientAttachment.getId())) {
+                    workClientAttachment.preInsert();
+                    workClientAttachmentDao.insert(workClientAttachment);
+                } else {
+                    workClientAttachment.preUpdate();
+                    workClientAttachmentDao.update(workClientAttachment);
+                }
+            } else {
+                workClientAttachmentDao.delete(workClientAttachment);
+            }
+        }
+    }
+
+    @Transactional(readOnly = false)
+	public void delete(WorkSendMessage workSendMessage) {
+		super.delete(workSendMessage);
+	}
+
+    @Transactional(readOnly = false)
+    public String saveMessage(WorkSendMessage workSendMessage) {
+        this.save(workSendMessage);
+        return this.startAudit(workSendMessage,workSendMessage.getProcessInstanceId());
+    }
+
+    private String startAudit(WorkSendMessage workSendMessage, String processInstanceId) {
+        Map<String, Object> variables = new HashMap<String, Object>();
+        identityService.setAuthenticatedUserId(workSendMessage.getCurrentUser().getId());
+        String contentStr = "发文文号:"+workSendMessage.getNum()+",发文类型:"+ DictUtils.getMainDictLabel(workSendMessage.getDocType(),"doc_type","")+",发文日期:"+ DateUtils.formatDate(workSendMessage.getCreateDate());
+        String titleStr = "发文标题:"+ workSendMessage.getTitle();
+
+        String businessKey = workSendMessage.getId();
+        Office office = UserUtils.getSelectOffice();
+        WorkActivityMenu workActivityMenu = workActivityMenuService.findByParentAndOffice("ggh3125f1f194582bdda9abcew750904", office);
+        // 启动流程
+        String processType = workActivityMenu.getProcessType();
+        StringBuffer buffer = new StringBuffer();
+        Activity activity = new Activity();
+        WorkProjectNotify workProjectNotify = UtilNotify
+                .saveNotify(workSendMessage.getId(),
+                        null,
+                        workSendMessage.getCompany().getId(),
+                        titleStr,
+                        contentStr,
+                        "62",
+                        "0",
+                        "待审批",
+                        ""
+                );
+
+        List<User> users = new ArrayList<>();
+        List<User> zjlList = UserUtils.getByRoleActivityEnname("zjl",3,workSendMessage.getOffice().getId(),"11",workSendMessage.getCreateBy());
+        if (StringUtils.isNotBlank(workActivityMenu.getId())) {
+            workProjectNotify.setNotifyRole("");
+            workActivityMenu = workActivityMenuService.get(workActivityMenu.getId());
+            List<Activity> activities = workActivityMenu.getActivities();
+            for (Activity a : activities) {
+                String encount = a.getEncount();
+                String enlist = a.getEnlist();
+                if (a.getRole()!=null && StringUtils.isNotBlank(a.getRole().getEnname())){
+                    List enusers = UserUtils.getByRoleActivityEnnames(a.getRole().getEnname(),office.getId(),"11",workSendMessage.getCreateBy());
+                    if (enusers.size()==0){
+                        workSendMessage.setState(ProjectStatusEnum.TSTORE.getValue());
+                        this.updateStatusById(workSendMessage);
+                        return "流程审批人不能为空,角色"+a.getRole().getName()+"下无用户,请联系管理员!";
+                    }
+                    variables.put(enlist, enusers);
+                    variables.put(encount, enusers.size());
+                }
+                if (a.getDelFlag().equals("0") && a.getCount() == 1) {
+                    activity = a;
+                }
+            }
+            buffer.append(activity.getRole().getEnname());
+            if (activity != null && StringUtils.isNotBlank(activity.getId())) {
+                //角色审批
+                if (StringUtils.isNotBlank(activity.getRole().getEnname())) {
+                    users = UserUtils.getByRoleActivityEnnames(activity.getRole().getEnname(),office.getId(),"11",workSendMessage.getCreateBy());
+                }
+                //人员审批
+                if (StringUtils.isNotBlank(activity.getUser().getId())) {
+                    users.add(activity.getUser());
+                }
+            }
+            workProjectNotify.setId("");
+        } else {
+            if (zjlList.size()==0 ){
+                workSendMessage.setState(ProjectStatusEnum.TSTORE.getValue());
+                this.updateStatusById(workSendMessage);
+            }
+            if (zjlList.size()==0){
+                return "流程审批人不能为空,总经理下无用户,请联系管理员!";
+            }
+            processType = "workSendMessage";
+            users.addAll(zjlList);
+        }
+        List<String> userIds = new ArrayList<>(users.size());
+        for (User u : users){
+            userIds.add(u.getId());
+            workProjectNotify.setUser(u);
+            workProjectNotify.setId("");
+            workProjectNotify.setNotifyRole("总经理审批");
+            workProjectNotifyService.save(workProjectNotify);
+            Map<String,Object> extras = new HashMap<>();
+            extras.put("type","7002");
+            extras.put("procDefKey","62");
+            extras.put("id",workProjectNotify.getId());
+            UserUtils.pushInfoToApp(titleStr, contentStr,extras,u.getId());
+        }
+        UserUtils.pushIm(userIds,contentStr);
+
+        variables.put("busId", businessKey);
+        variables.put("type", processType);
+        variables.put("title", "审批单:" + workSendMessage.getNum());//设置标题;
+
+        ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(processType, businessKey, variables);
+        //        workReceiptsSettle.setProcessInstance(processInstance);
+        if (org.apache.commons.lang3.StringUtils.isNotBlank(processInstanceId)) {
+            workActivityProcessService.updateProcessInstanceId(processInstance.getId(),processInstanceId);
+            workActivityProcessService.deleteProcessInstanceId(processInstanceId);
+            workActivityProcessService.deleteProcessIdAuditUsers(processInstanceId);
+        }
+        List<Activity> list = workActivityMenu.getActivities();
+        if (list != null && list.size() != 0) {
+            workActivityProcessService.saveList(list, processInstance.getId());
+        } else {
+            WorkActivityProcess workActivityProcess = new WorkActivityProcess();
+            workActivityProcess.setProcessKey(processType);
+            workActivityProcess.setCount(1);
+            workActivityProcess.setIsApproval("0");
+            workActivityProcess.setProcessInstanceId(processInstance.getId());
+            workActivityProcessService.save(workActivityProcess);
+            workActivityProcessService.insertAuditsByType(zjlList,processInstance.getId(),1,1);
+        }
+        workSendMessage.setProcessInstanceId(processInstance.getId());
+        workSendMessage.setState(ProjectStatusEnum.IN_APRL.getValue());
+        dao.updateProcessIdAndStatus(workSendMessage);
+        return "";
+    }
+
+    private void updateStatusById(WorkSendMessage workSendMessage) {
+        dao.updateStatusById(workSendMessage);
+    }
+
+    @Transactional(readOnly = false)
+    public void cancelProcess(WorkSendMessage workSendMessage) throws Exception {
+        WorkActivityProcess process = new WorkActivityProcess();
+        process.setProcessInstanceId(workSendMessage.getProcessInstanceId());
+        process.setIsApproval("0");
+        //List<WorkActivityProcess> processList1 = workActivityProcessService.findByProcInsId(process);
+        WorkActivityProcess workActivityProcess = new WorkActivityProcess();
+        workActivityProcess.setProcessInstanceId(workSendMessage.getProcessInstanceId());
+        List<WorkActivityProcess> processList = workActivityProcessService.findList(workActivityProcess);
+        WorkProjectNotify notify = new WorkProjectNotify();
+        notify.setNotifyId(workSendMessage.getId());
+        List<User> userList = workProjectNotifyService.readByNotifyId(notify);
+        if (userList!=null && userList.size()!=0) {
+            for (User u : userList) {
+                User user = UserUtils.get(u.getId());
+                /*List<WebSocket> toUserConns = ChatServerPool.getWebSocketByUser(u.getId());
+                for (WebSocket toUserConn : toUserConns) {
+                    String message = "{\"to\":\""+u.getId()+"\"," +
+                            "\"msg\":\"审批信息 申请人:"+ user.getName()+",发文审批编号:"+workSendMessage.getNum() +" 强制撤销!\"," +
+                            "\"useType\":\"sys\"}";
+                    ChatServerPool.sendMessageToUser(toUserConn, message);//同时向本人发送消息
+                    //ChatServerPool.sendMessageToUser(toUserConn, u.getId() + "_sys_审批信息 " + "报销人:" + user.getName() + ",报销编号:" + workReimbursement.getNumber() + " 强制撤销!");//同时向本人发送消息
+                }*/
+                UserUtils.pushIm(u.getId(),"申请人:"+ user.getName()+",发文审批编号:"+workSendMessage.getNum() +" 强制撤销!");
+            }
+        }
+        if(processList!=null && processList.size()>0){
+            for (int i =0;i<processList.size();i++) {
+                WorkActivityProcess p = processList.get(i);
+                if(StringUtils.isNotBlank(p.getIsApproval()) && "0".equals(p.getIsApproval())){
+                    p.setIsApproval("-1");
+                    p.setDelFlag("1");
+                    workActivityProcessDao.updateDelFlagAndIsApproval(p);
+                }
+            }
+            WorkActivityProcess pro = new WorkActivityProcess();
+            pro.setId("");
+            pro.setDelFlag("0");
+            pro.preInsert();
+            pro.setRemarks("[强制撤销]");
+            pro.setProcessKey(processList.get(0).getProcessKey());
+            pro.setIsApproval("1");
+            pro.setProcessInstanceId(processList.get(0).getProcessInstanceId());
+            pro.setCount(0);
+            workActivityProcessDao.insert(pro);
+
+            //结束该流程,设为"撤销"状态月
+            WorkSendMessage sendMessage = new WorkSendMessage();
+            sendMessage.setId(workSendMessage.getId());
+            sendMessage.setState(ProjectStatusEnum.RECALL.getValue());
+            sendMessage.setProcessInstanceId(workSendMessage.getProcessInstanceId());
+            sendMessage.preUpdate();
+            dao.updateProcessIdAndStatus(sendMessage);
+            actTaskService.endProcessInstance(workSendMessage.getProcessInstanceId(), "发文申请-撤回");
+        }
+    }
+
+    @Transactional(readOnly = false)
+    public String auditSave(WorkSendMessage workSendMessage,List<User> auditUsers) {
+        try {
+            String str = "发文文号:"+workSendMessage.getNum()+",发文类型:"+ DictUtils.getMainDictLabel(workSendMessage.getDocType(),"doc_type","")+",发文日期:"+ DateUtils.formatDate(workSendMessage.getCreateDate());
+            String title = "发文标题:"+ workSendMessage.getTitle();
+            // 对不同环节的业务逻辑进行操作
+            String taskDefKey = workSendMessage.getAct().getTaskDefKey();
+            if (!"modifyApply".equals(taskDefKey) && !taskDefKey.contains("audit")) {
+                actTaskService.claim(workSendMessage.getAct().getTaskId(), UserUtils.getUser().getId());
+            }else {
+                workSendMessage.getAct().setFlag("yes");
+                this.save(workSendMessage);
+            }
+            String comment = "";
+            if (ProjectStatusEnum.REJECTED.getValue() == workSendMessage.getState()){
+                comment = ("yes".equals(workSendMessage.getAct().getFlag())?"[重新申请] ":"[已撤销] ");
+            }else {
+                comment = ("yes".equals(workSendMessage.getAct().getFlag())?"[同意] ":"[驳回] ")+ workSendMessage.getAct().getComment();
+            }
+            //yes 的时候状态为审核通过 否则为未通过
+            //1 审核中 2 未通过
+            workSendMessage.setState(("yes".equals(workSendMessage.getAct().getFlag()) ? ProjectStatusEnum.IN_APRL.getValue() : ProjectStatusEnum.REJECTED.getValue()));
+            Map<String, Object> vars = Maps.newHashMap();
+            //业务逻辑对应的条件表达式
+            String exp = "";
+            String taskCount = "";
+            String notifyRole = "";
+            int key = 0;
+            String enname = "";
+            List<Activity> activitieList = activityService.getByProcessInstanceId(workSendMessage.getProcessInstanceId());
+            WorkActivityMenu workActivityMenu = new WorkActivityMenu();
+            if (activitieList != null && activitieList.size() != 0) {
+                workActivityMenu.setProcessType(activitieList.get(0).getProcessKey());
+                workActivityMenu.setActivities(activitieList);
+            }
+
+            WorkActivityProcess workActivityProcess = new WorkActivityProcess();
+            WorkActivityProcess selectProcess = new WorkActivityProcess();
+            selectProcess.setProcessInstanceId(workSendMessage.getProcessInstanceId());
+            List<WorkActivityProcess> workActivityProcesses = workActivityProcessService.findList(selectProcess);
+            List<Activity> activities = workActivityMenu.getActivities();
+            if (StringUtils.isNotBlank(workActivityMenu.getProcessType()) && !workActivityMenu.getProcessType().equals("workSendMessage")) {
+                key = 1;
+                for (int i = 0; i < workActivityProcesses.size(); i++) {
+                    WorkActivityProcess activityProcess = workActivityProcesses.get(i);
+                    if (taskDefKey.equals(activityProcess.getActivityTask()) && !taskDefKey.equals("modifyApply")) {
+                        taskCount = activityProcess.getCount()+"";
+                        workActivityProcess = activityProcess;
+                        if (!workActivityProcess.getIsApproval().equals("0")) {
+                            workActivityProcess.setId("");
+                        }
+                        exp = "pass";
+                        if (!"yes".equals(workSendMessage.getAct().getFlag())) {
+                            notifyRole = "调整发文";
+                            workSendMessage.setState(ProjectStatusEnum.REJECTED.getValue());
+                            workActivityProcess.setIsApproval("2");
+                            String returnBack = "-1";
+                            for (Activity activity : activities) {
+                                if (activity.getCount() == activityProcess.getCount()) {
+                                    notifyRole = activity.getName();
+                                    returnBack = activity.getReturnBack();
+                                    break;
+                                }
+                            }
+                            if (returnBack.equals("0")) {
+                                workActivityProcess.setId("");
+                            }
+
+                        } else {
+                            workActivityProcess.setIsApproval("1");
+                        }
+                    }else if(taskDefKey.equals("modifyApply")){
+                        taskCount = "0";
+                        exp = "pass";
+                        workActivityProcess.setId("");
+                        workActivityProcess.setCount(0);
+                        if (!"yes".equals(workSendMessage.getAct().getFlag())) {
+                            workSendMessage.setState(ProjectStatusEnum.RECALL.getValue());
+                            workActivityProcess.setIsApproval("2");
+                        } else {
+                            workActivityProcess.setIsApproval("1");
+                        }
+                        break;
+                    }
+                }
+            } else {
+                workActivityMenu.setProcessType("workSendMessage");
+                for (int i = 0; i < workActivityProcesses.size(); i++) {
+                    WorkActivityProcess activityProcess = workActivityProcesses.get(i);
+                    String count = activityProcess.getCount() + "";
+                    workActivityProcess = activityProcess;
+                    if (!workActivityProcess.getIsApproval().equals("0")) {
+                        workActivityProcess.setId("");
+                    }
+                    // 审核环节
+                    if ("zjl".equals(taskDefKey) && count.contains("1")) {
+                        taskCount = "1";
+                        exp = "pass";
+                        if ("yes".equals(workSendMessage.getAct().getFlag())) {
+                            notifyRole = "审批通过";
+                            workActivityProcess.setIsApproval("1");
+                        } else {
+                            notifyRole = "调整发文";
+                            workActivityProcess.setIsApproval("2");
+                        }
+                        break;
+                    } else if ("modifyApply".equals(taskDefKey)&& count.contains("0")) {
+                        notifyRole = "总经理审批";
+                        taskCount = "0";
+                        exp = "pass";
+                        workActivityProcess.setCount(0);
+                        enname = "zjl";
+                        if (!"yes".equals(workSendMessage.getAct().getFlag())) {
+                            workSendMessage.setState(ProjectStatusEnum.RECALL.getValue());
+                        }
+                        break;
+                    } else if ("apply_end".equals(taskDefKey)) {
+                    }
+
+                }
+            }
+            // 设置意见
+            workSendMessage.getAct().setComment(("yes".equals(workSendMessage.getAct().getFlag()) ? "[同意] " : "[驳回] ") + workSendMessage.getAct().getComment());
+            workSendMessage.preUpdate();
+            // 提交流程任务
+            vars.put(exp, "yes".equals(workSendMessage.getAct().getFlag()) ? true : false);
+            workActivityProcessService.updateProcess(workActivityProcess,workActivityMenu,key,taskCount, workSendMessage.getProcessInstanceId(),taskDefKey,"modifyApply", workSendMessage.getAct().getFlag(),comment, activities);
+            // 提交流程任务
+            actTaskService.complete(workSendMessage.getAct().getTaskId(), workSendMessage.getAct().getProcInsId(), workSendMessage.getAct().getComment(), vars);
+            boolean state = actTaskService.isProcessEnd(workSendMessage.getAct().getProcInsId());
+            List<User> users = new ArrayList<>();
+            List<User> userList = new ArrayList<>();
+            if (!state) {
+                users.add(workSendMessage.getCreateBy());
+                if ("yes".equals(workSendMessage.getAct().getFlag())) {
+                    workSendMessage.setState(ProjectStatusEnum.SIGNED.getValue());
+                    WorkProjectNotify notify = new WorkProjectNotify();
+                    notify.setNotifyId(workSendMessage.getId());
+                    userList = workProjectNotifyService.readByNotifyId(notify);
+                    workProjectNotifyService
+                            .save(UtilNotify
+                                    .saveNotify(workSendMessage.getId(),
+                                            workSendMessage.getCreateBy(),
+                                            workSendMessage.getCompany().getId(),
+                                            title,
+                                            str,
+                                            "62",
+                                            "0",
+                                            "待通知",
+                                            notifyRole));
+
+                } else {
+                    WorkProjectNotify notify = new WorkProjectNotify();
+                    notify.setNotifyId(workSendMessage.getId());
+                    userList = workProjectNotifyService.readByNotifyId(notify);
+                    if (ProjectStatusEnum.RECALL.getValue() != workSendMessage.getState()){
+                        workSendMessage.setState(ProjectStatusEnum.REJECTED.getValue());
+                        workProjectNotifyService
+                                .save(UtilNotify
+                                        .saveNotify(workSendMessage.getId(),
+                                                workSendMessage.getCreateBy(),
+                                                workSendMessage.getCompany().getId(),
+                                                title,
+                                                str,
+                                                "62",
+                                                "0",
+                                                "待通知",
+                                                notifyRole));
+                    }
+                }
+                workActivityProcessService.deleteProcessIdAuditUsers(workSendMessage.getProcessInstanceId());
+            } else {
+                if (StringUtils.isNotBlank(workActivityMenu.getProcessType()) && !workActivityMenu.getProcessType().equals("workSendMessage")) {
+                    WorkProjectNotify notify = new WorkProjectNotify();
+                    notify.setNotifyId(workSendMessage.getId());
+                    userList = workProjectNotifyService.readByNotifyId(notify);
+                    //users.addAll(userList);
+                    WorkProjectNotify workProjectNotify = UtilNotify
+                            .saveNotify(workSendMessage.getId(),
+                                    new User(),
+                                    workSendMessage.getCompany().getId(),
+                                    title,
+                                    str,
+                                    "62",
+                                    "0",
+                                    "待审批",
+                                    notifyRole);
+                    List<WorkProjectNotify> workProjectNotifys = activityService.getByFlagAndTaskDefKeyList(
+                            activities,
+                            workProjectNotify,
+                            taskDefKey,
+                            workSendMessage.getAct().getFlag(),
+                            taskCount,
+                            workSendMessage.getCreateBy(),
+                            workSendMessage.getOffice().getId(),
+                            "62");
+                    for (WorkProjectNotify workProjectNotify1:workProjectNotifys){
+                        users.add(workProjectNotify1.getUser());
+                        workProjectNotify1.setId("");
+                        workProjectNotify1.setIsNewRecord(false);
+                        workProjectNotifyService
+                                .save(workProjectNotify1);
+                    }
+
+                } else {
+                    if (!"yes".equals(workSendMessage.getAct().getFlag())) {
+                        WorkProjectNotify notify = new WorkProjectNotify();
+                        notify.setNotifyId(workSendMessage.getId());
+                        userList = workProjectNotifyService.readByNotifyId(notify);
+                        //users.addAll(userList);
+                        workProjectNotifyService
+                                .save(UtilNotify
+                                        .saveNotify(workSendMessage.getId(),
+                                                workSendMessage.getCreateBy(),
+                                                workSendMessage.getCompany().getId(),
+                                                title,
+                                                str,
+                                                "62",
+                                                "0",
+                                                "重新申请",
+                                                notifyRole));
+                        users.add( workSendMessage.getCreateBy());
+                    } else {
+                        if (StringUtils.isNotBlank(enname)) {
+                            WorkProjectNotify notify = new WorkProjectNotify();
+                            notify.setNotifyId(workSendMessage.getId());
+                            userList = workProjectNotifyService.readByNotifyId(notify);
+                            //users.addAll(userList1);
+                            WorkProjectNotify workProjectNotify = UtilNotify
+                                    .saveNotify(workSendMessage.getId(),
+                                            new User(),
+                                            workSendMessage.getCompany().getId(),
+                                            title,
+                                            str,
+                                            "62",
+                                            "0",
+                                            "待审批",
+                                            notifyRole);
+                            users.addAll(auditUsers);
+                            for (User user1:auditUsers){
+                                workProjectNotify.setUser(user1);
+                                workProjectNotify.setId("");
+                                workProjectNotify.setIsNewRecord(false);
+                                workProjectNotifyService.save(workProjectNotify);
+                                Map<String,Object> extras = new HashMap<>();
+                                extras.put("type","7002");
+                                extras.put("procDefKey","62");
+                                extras.put("id",workProjectNotify.getId());
+                                UserUtils.pushInfoToApp(title, str,extras,user1.getId());
+                            }
+                        }else {
+                            WorkProjectNotify notify = new WorkProjectNotify();
+                            notify.setNotifyId(workSendMessage.getId());
+                            userList = workProjectNotifyService.readByNotifyId(notify);
+                            users.add(workSendMessage.getCreateBy());
+                            workProjectNotifyService
+                                    .save(UtilNotify
+                                            .saveNotify(workSendMessage.getId(),
+                                                    workSendMessage.getCreateBy(),
+                                                    workSendMessage.getCompany().getId(),
+                                                    title,
+                                                    str,
+                                                    "62",
+                                                    "0",
+                                                    "重新申请",
+                                                    notifyRole));
+                        }
+                    }
+                }
+            }
+            if (StringUtils.isNotBlank(title) && users!=null && users.size()!=0) {
+                for (User u : users) {
+                    UserUtils.pushIm(u.getId(),title);
+                }
+            }
+            if (StringUtils.isNotBlank(title) && userList!=null && userList.size()!=0) {
+                for (User u : userList) {
+                    UserUtils.pushMeIm(u.getId());
+                }
+            }
+            dao.update(workSendMessage);
+            if(ProjectStatusEnum.SIGNED.getValue() == workSendMessage.getState()){
+                this.sendMessage(workSendMessage);
+            }
+            return "保存审核意见成功!";
+        }catch (ActivitiObjectNotFoundException e){
+            logger.error("ActivitiObjectNotFoundException e:",e);
+            return "流程已审批,不能重新审批!";
+        }catch (Exception e){
+            logger.error("Exception e:",e);
+            return "保存审核意见失败!!";
+        }
+    }
+
+    private void sendMessage(WorkSendMessage workSendMessage)throws Exception {
+	    try {
+            this.queryDetails(workSendMessage);
+            String contentStr = "发文标题:"+workSendMessage.getTitle()+",发文文号:"+workSendMessage.getNum()+",发文类型:"+ DictUtils.getMainDictLabel(workSendMessage.getDocType(),"doc_type","")+",发文日期:"+ DateUtils.formatDate(workSendMessage.getCreateDate());
+            String titleStr = "您收到"+workSendMessage.getOffice().getName()+"的发文,请查阅!";
+            String remark = "待通知";
+            WorkProjectNotify workProjectNotify = UtilNotify.saveNotify(workSendMessage.getId(), null, workSendMessage.getCompany().getId(),
+                    titleStr, contentStr, "73", "0", remark, "");
+            List<User> userList = workSendMessage.getUserList();
+            List<Office> officeList = workSendMessage.getOfficeList();
+            User user = new User();
+            Set<String> userIds = new HashSet<>(userList.size());
+            for (User u : userList) {
+                userIds.add(u.getId());
+            }
+            for (Office office : officeList) {
+                user.setOffice(office);
+                List<User> users = userDao.findUserByOfficeId(user);
+                if (users != null && users.size() > 0) {
+                    for (User user1 : users) {
+                        userIds.add(user1.getId());
+                    }
+                }
+            }
+            for (String userId : userIds) {
+                workProjectNotify.setUser(new User(userId));
+                workProjectNotify.setId("");
+                workProjectNotify.setNotifyRole("");
+                workProjectNotifyService.save(workProjectNotify);
+            }
+            UserUtils.pushIm(new ArrayList<String>(userIds), contentStr);
+        }catch (Exception e){
+	        throw e;
+        }
+    }
+
+    public Page<WorkSendMessage> findMemberPage(Page<WorkSendMessage> page, WorkSendMessage workSendMessage) {
+        workSendMessage.setPage(page);
+        page.setList(dao.queryMemberPage(workSendMessage));
+        return page;
+    }
+}

+ 384 - 0
src/main/java/com/jeeplus/modules/worksendmessage/web/WorkSendMessageController.java

@@ -0,0 +1,384 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.worksendmessage.web;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.validation.ConstraintViolationException;
+
+import com.jeeplus.modules.act.entity.Act;
+import com.jeeplus.modules.act.service.ActTaskService;
+import com.jeeplus.modules.projectrecord.enums.ProjectStatusEnum;
+import com.jeeplus.modules.sys.entity.User;
+import com.jeeplus.modules.sys.utils.UserUtils;
+import com.jeeplus.modules.workincomingmessage.entity.WorkIncomingMessage;
+import org.activiti.engine.runtime.ProcessInstance;
+import org.activiti.engine.task.Task;
+import org.apache.shiro.authz.annotation.Logical;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.servlet.mvc.support.RedirectAttributes;
+
+import com.google.common.collect.Lists;
+import com.jeeplus.common.utils.DateUtils;
+import com.jeeplus.common.utils.MyBeanUtils;
+import com.jeeplus.common.config.Global;
+import com.jeeplus.common.persistence.Page;
+import com.jeeplus.common.web.BaseController;
+import com.jeeplus.common.utils.StringUtils;
+import com.jeeplus.common.utils.excel.ExportExcel;
+import com.jeeplus.common.utils.excel.ImportExcel;
+import com.jeeplus.modules.worksendmessage.entity.WorkSendMessage;
+import com.jeeplus.modules.worksendmessage.service.WorkSendMessageService;
+
+/**
+ * 发文管理Controller
+ * @author ssrh
+ * @version 2018-07-12
+ */
+@Controller
+@RequestMapping(value = "${adminPath}/worksendmessage/workSendMessage")
+public class WorkSendMessageController extends BaseController {
+
+	@Autowired
+	private WorkSendMessageService workSendMessageService;
+    @Autowired
+    private ActTaskService actTaskService;
+	
+	@ModelAttribute
+	public WorkSendMessage get(@RequestParam(required=false) String id) {
+		WorkSendMessage entity = null;
+		if (StringUtils.isNotBlank(id)){
+			entity = workSendMessageService.get(id);
+		}
+		if (entity == null){
+			entity = new WorkSendMessage();
+		}
+		return entity;
+	}
+	
+	/**
+	 * 发文管理列表页面
+	 */
+	@RequiresPermissions("worksendmessage:workSendMessage:list")
+	@RequestMapping(value = {"list", ""})
+	public String list(WorkSendMessage workSendMessage, HttpServletRequest request, HttpServletResponse response, Model model) {
+		Page<WorkSendMessage> page = workSendMessageService.findPage(new Page<WorkSendMessage>(request, response), workSendMessage); 
+		model.addAttribute("page", page);
+		return "modules/worksendmessage/workSendMessageList";
+	}
+
+	/**
+	 * 查看,增加,编辑发文管理表单页面
+	 */
+	@RequiresPermissions(value={"worksendmessage:workSendMessage:add","worksendmessage:workSendMessage:edit"},logical=Logical.OR)
+	@RequestMapping(value = "form")
+	public String form(WorkSendMessage workSendMessage, Model model) {
+	    if(workSendMessage.getCreateDate()==null){
+	        workSendMessage.setCreateDate(new Date());
+        }
+        if(StringUtils.isNotBlank(workSendMessage.getId())){
+            workSendMessageService.queryDetails(workSendMessage);
+        }
+        if(workSendMessage.getOffice()==null||StringUtils.isBlank(workSendMessage.getOffice().getId())){
+	        workSendMessage.setOffice(UserUtils.getSelectOffice());
+        }
+		model.addAttribute("workSendMessage", workSendMessage);
+		return "modules/worksendmessage/workSendMessageForm";
+	}
+
+    /**
+     * 查看,增加,编辑收文管理表单页面
+     */
+    @RequiresPermissions(value={"worksendmessage:workSendMessage:view"},logical=Logical.OR)
+    @RequestMapping(value = "view")
+    public String view(WorkSendMessage workSendMessage, Model model) {
+        if(StringUtils.isNotBlank(workSendMessage.getId())){
+            workSendMessageService.queryDetails(workSendMessage);
+        }
+        model.addAttribute("workSendMessage", workSendMessage);
+        return "modules/worksendmessage/workSendMessageView";
+    }
+
+    /**
+     * 发文管理列表页面
+     */
+    @RequestMapping(value = {"memberList"})
+    public String memberList(WorkSendMessage workSendMessage, HttpServletRequest request, HttpServletResponse response, Model model) {
+        Page<WorkSendMessage> page = workSendMessageService.findMemberPage(new Page<WorkSendMessage>(request, response), workSendMessage);
+        model.addAttribute("page", page);
+        return "modules/worksendmessage/workSendMessageMemberList";
+    }
+
+    /**
+     * 查看,增加,编辑收文管理表单页面
+     */
+    @RequestMapping(value = "memberView")
+    public String memberView(WorkSendMessage workSendMessage, Model model) {
+        if(StringUtils.isNotBlank(workSendMessage.getId())){
+            workSendMessageService.queryDetails(workSendMessage);
+        }
+        model.addAttribute("workSendMessage", workSendMessage);
+        return "modules/worksendmessage/workSendMessageMemberView";
+    }
+
+	/**
+	 * 保存发文管理
+	 */
+	@RequiresPermissions(value={"worksendmessage:workSendMessage:add","worksendmessage:workSendMessage:edit"},logical=Logical.OR)
+	@RequestMapping(value = "save")
+	public String save(WorkSendMessage workSendMessage, Model model, RedirectAttributes redirectAttributes) throws Exception{
+		if (!beanValidator(model, workSendMessage)){
+			return form(workSendMessage, model);
+		}
+        workSendMessage.setState(ProjectStatusEnum.IN_APRL.getValue());
+        String str = "";
+        if(!workSendMessage.getIsNewRecord()){//编辑表单保存
+            WorkSendMessage t = workSendMessageService.get(workSendMessage.getId());//从数据库取出记录的值
+            MyBeanUtils.copyBeanNotNull2Bean(workSendMessage, t);//将编辑表单中的非NULL值覆盖数据库记录中的值
+            str = workSendMessageService.saveMessage(t);//保存
+        }else{//新增表单保存
+            str = workSendMessageService.saveMessage(workSendMessage);//保存
+        }
+        if (StringUtils.isNotBlank(str)){
+            addMessage(redirectAttributes, "保存发文管理失败:"+str);
+        }else {
+            addMessage(redirectAttributes, "保存发文管理成功");
+        }
+		return "redirect:"+Global.getAdminPath()+"/worksendmessage/workSendMessage/?repage";
+	}
+	/**
+	 * 保存发文管理
+	 */
+	@RequiresPermissions(value={"worksendmessage:workSendMessage:add","worksendmessage:workSendMessage:edit"},logical=Logical.OR)
+	@RequestMapping(value = "tstore")
+	public String tstore(WorkSendMessage workSendMessage, Model model, RedirectAttributes redirectAttributes) throws Exception{
+		if (!beanValidator(model, workSendMessage)){
+			return form(workSendMessage, model);
+		}
+        workSendMessage.setState(ProjectStatusEnum.TSTORE.getValue());
+        if(!workSendMessage.getIsNewRecord()){//编辑表单保存
+            WorkSendMessage t = workSendMessageService.get(workSendMessage.getId());//从数据库取出记录的值
+            MyBeanUtils.copyBeanNotNull2Bean(workSendMessage, t);//将编辑表单中的非NULL值覆盖数据库记录中的值
+            workSendMessageService.save(t);//保存
+        }else{//新增表单保存
+            workSendMessageService.save(workSendMessage);//保存
+        }
+        addMessage(redirectAttributes, "暂存发文管理成功");
+		return "redirect:"+Global.getAdminPath()+"/worksendmessage/workSendMessage/?repage";
+	}
+	
+	/**
+	 * 删除发文管理
+	 */
+	@RequiresPermissions("worksendmessage:workSendMessage:del")
+	@RequestMapping(value = "delete")
+	public String delete(WorkSendMessage workSendMessage, RedirectAttributes redirectAttributes) {
+        Integer sta = workSendMessage.getState();
+        if(5==sta|| 2==sta){
+            if(5==sta){
+                addMessage(redirectAttributes, "发文信息已审批通过,无法删除");
+                return "redirect:"+Global.getAdminPath()+"/worksendmessage/workSendMessage/?repage";
+            }else{
+                addMessage(redirectAttributes, "发文信息正在审核中,无法删除");
+                return "redirect:"+Global.getAdminPath()+"/worksendmessage/workSendMessage/?repage";
+            }
+        }
+		workSendMessageService.delete(workSendMessage);
+		addMessage(redirectAttributes, "删除发文管理成功");
+		return "redirect:"+Global.getAdminPath()+"/worksendmessage/workSendMessage/?repage";
+	}
+	
+	/**
+	 * 批量删除发文管理
+	 */
+	@RequiresPermissions("worksendmessage:workSendMessage:del")
+	@RequestMapping(value = "deleteAll")
+	public String deleteAll(String ids, RedirectAttributes redirectAttributes) {
+		String idArray[] =ids.split(",");
+		for(String id : idArray){
+			workSendMessageService.delete(workSendMessageService.get(id));
+		}
+		addMessage(redirectAttributes, "删除发文管理成功");
+		return "redirect:"+Global.getAdminPath()+"/worksendmessage/workSendMessage/?repage";
+	}
+	
+	/**
+	 * 导出excel文件
+	 */
+	@RequiresPermissions("worksendmessage:workSendMessage:export")
+    @RequestMapping(value = "export", method=RequestMethod.POST)
+    public String exportFile(WorkSendMessage workSendMessage, HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) {
+		try {
+            String fileName = "发文管理"+DateUtils.getDate("yyyyMMddHHmmss")+".xlsx";
+            Page<WorkSendMessage> page = workSendMessageService.findPage(new Page<WorkSendMessage>(request, response, -1), workSendMessage);
+    		new ExportExcel("发文管理", WorkSendMessage.class).setDataList(page.getList()).write(response, fileName).dispose();
+    		return null;
+		} catch (Exception e) {
+			addMessage(redirectAttributes, "导出发文管理记录失败!失败信息:"+e.getMessage());
+		}
+		return "redirect:"+Global.getAdminPath()+"/worksendmessage/workSendMessage/?repage";
+    }
+
+	/**
+	 * 导入Excel数据
+
+	 */
+	@RequiresPermissions("worksendmessage:workSendMessage:import")
+    @RequestMapping(value = "import", method=RequestMethod.POST)
+    public String importFile(MultipartFile file, RedirectAttributes redirectAttributes) {
+		try {
+			int successNum = 0;
+			int failureNum = 0;
+			StringBuilder failureMsg = new StringBuilder();
+			ImportExcel ei = new ImportExcel(file, 1, 0);
+			List<WorkSendMessage> list = ei.getDataList(WorkSendMessage.class);
+			for (WorkSendMessage workSendMessage : list){
+				try{
+					workSendMessageService.save(workSendMessage);
+					successNum++;
+				}catch(ConstraintViolationException ex){
+					failureNum++;
+				}catch (Exception ex) {
+					failureNum++;
+				}
+			}
+			if (failureNum>0){
+				failureMsg.insert(0, ",失败 "+failureNum+" 条发文管理记录。");
+			}
+			addMessage(redirectAttributes, "已成功导入 "+successNum+" 条发文管理记录"+failureMsg);
+		} catch (Exception e) {
+			addMessage(redirectAttributes, "导入发文管理失败!失败信息:"+e.getMessage());
+		}
+		return "redirect:"+Global.getAdminPath()+"/worksendmessage/workSendMessage/?repage";
+    }
+	
+	/**
+	 * 下载导入发文管理数据模板
+	 */
+	@RequiresPermissions("worksendmessage:workSendMessage:import")
+    @RequestMapping(value = "import/template")
+    public String importFileTemplate(HttpServletResponse response, RedirectAttributes redirectAttributes) {
+		try {
+            String fileName = "发文管理数据导入模板.xlsx";
+    		List<WorkSendMessage> list = Lists.newArrayList(); 
+    		new ExportExcel("发文管理数据", WorkSendMessage.class, 1).setDataList(list).write(response, fileName).dispose();
+    		return null;
+		} catch (Exception e) {
+			addMessage(redirectAttributes, "导入模板下载失败!失败信息:"+e.getMessage());
+		}
+		return "redirect:"+Global.getAdminPath()+"/worksendmessage/workSendMessage/?repage";
+    }
+
+    @RequiresPermissions(value={"worksendmessage:workSendMessage:edit"},logical=Logical.OR)
+    @RequestMapping(value = "modify")
+    public String modify(WorkSendMessage workSendMessage, Model model,RedirectAttributes redirectAttributes) {
+        workSendMessage=workSendMessageService.get(workSendMessage.getId());
+        if(StringUtils.isNotBlank(workSendMessage.getId())){
+            workSendMessageService.queryDetails(workSendMessage);
+        }
+        ProcessInstance processInstance = actTaskService.getProcIns(workSendMessage.getProcessInstanceId());
+        if (processInstance!=null) {
+            Task taskInfok = actTaskService.getCurrentTaskInfo(processInstance);
+            Act act = new Act();
+            act.setTaskId(taskInfok.getId());
+            act.setTaskName(taskInfok.getName());
+            act.setTaskDefKey(taskInfok.getTaskDefinitionKey());
+            act.setProcDefId(taskInfok.getProcessDefinitionId());
+            act.setProcInsId(taskInfok.getProcessInstanceId());
+            act.setTask(taskInfok);
+            workSendMessage.setAct(act);
+        }
+
+        model.addAttribute("workSendMessage", workSendMessage);
+        return "modules/worksendmessage/workSendMessageModifyApply";
+    }
+
+    /**
+     * 工单执行(完成任务)
+     * @param model
+     * @return
+     */
+    @RequestMapping(value = "saveAudit")
+    public String saveAudit(WorkSendMessage workSendMessage, Model model,
+                            RedirectAttributes redirectAttributes) {
+        try {
+            List<User> users = UserUtils.getByProssType(workSendMessage.getProcessInstanceId(),1);
+            String flag = workSendMessage.getAct().getFlag();
+            if ("yes".equals(flag) && (users==null || users.size()==0)){
+                addMessage(redirectAttributes, "审批失败,审批人为空,请联系管理员!");
+            }else {
+                String str = workSendMessageService.auditSave(workSendMessage, users);
+                addMessage(redirectAttributes, str);
+            }
+        }catch (Exception e){
+            addMessage(redirectAttributes, "发文管理流程审批失败");
+        }
+
+        if (StringUtils.isNotBlank(workSendMessage.getHome()) && "home".equals(workSendMessage.getHome())){
+            return "redirect:" + Global.getAdminPath() + "/home/?repage";
+        }else {
+            return "redirect:" + Global.getAdminPath() + "/worksendmessage/workSendMessage/?repage";
+        }
+    }
+
+    //	审批页面
+    @RequestMapping(value = "audit")
+    public String workContractInfoAudit(Act act, WorkSendMessage workSendMessage, Model model) {
+        if(StringUtils.isNotBlank(workSendMessage.getId())){
+            workSendMessageService.queryDetails(workSendMessage);
+        }
+        if (act.getProcInsId() != null) {
+            if (actTaskService.getProcIns(act.getProcInsId()) != null) {
+                act.setProcIns(actTaskService.getProcIns(act.getProcInsId()));
+            } else {
+                act.setFinishedProcIns(actTaskService.getFinishedProcIns(act.getProcInsId()));
+            }
+        }
+        if (act != null && StringUtils.isNotBlank(act.getTaskId())) {
+            workSendMessage.setAct(act);
+            model.addAttribute("processInstanceId", workSendMessage.getProcessInstanceId());
+        }
+        model.addAttribute("workSendMessage", workSendMessage);
+        return "modules/worksendmessage/workSendMessageAudit";
+    }
+
+    @RequestMapping(value = "getProcess")
+    public String getProcess(WorkSendMessage workSendMessage, Model model, HttpServletRequest request){
+        model.addAttribute("processInstanceId", workSendMessage.getProcessInstanceId());
+        return "modules/worksendmessage/workSendMessageTask";
+    }
+
+    @RequiresPermissions(value={"worksendmessage:workSendMessage:edit"},logical=Logical.OR)
+    @RequestMapping(value = "revoke")
+    public String revoke(HttpServletRequest request, RedirectAttributes redirectAttributes) {
+        HashMap<String, String> requestMap = findRequestMap(request);
+        String processInstanceId = requestMap.get("processInstanceId");
+        String id = requestMap.get("id");
+        try {
+            WorkSendMessage workSendMessage = workSendMessageService.get(id);
+            if(5==workSendMessage.getState()){
+                addMessage(redirectAttributes, "发文信息已审批通过,无法撤回");
+                return "redirect:"+Global.getAdminPath()+"/worksendmessage/workSendMessage/?repage";
+            }
+            workSendMessageService.cancelProcess(workSendMessage);
+            addMessage(redirectAttributes, "撤回该发文审批成功");
+        }catch (Exception e){
+            logger.info(e.getMessage());
+            addMessage(redirectAttributes, "撤回该发文审批失败");
+        }
+        return "redirect:" + Global.getAdminPath() + "/worksendmessage/workSendMessage/?repage";
+    }
+}

+ 30 - 0
src/main/java/com/jeeplus/modules/worksinglewage/dao/WorkSingleWageDao.java

@@ -0,0 +1,30 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.worksinglewage.dao;
+
+import com.jeeplus.common.persistence.CrudDao;
+import com.jeeplus.common.persistence.annotation.MyBatisDao;
+import com.jeeplus.modules.worksinglewage.entity.WorkSingleWage;
+
+/**
+ * 单项工资DAO接口
+ * @author 杨帆
+ * @version 2018-09-26
+ */
+@MyBatisDao
+public interface WorkSingleWageDao extends CrudDao<WorkSingleWage> {
+    /**
+     * 更新流程实例ID
+     * @return
+     */
+    public int updateProcessInstanceId(WorkSingleWage workSingleWage);
+
+    /**
+     * 根据流程实例ID获取WorkReimbursement
+     * @param processInstanceId
+     * @return
+     */
+    public WorkSingleWage getByProcessInstanceId(String processInstanceId);
+	
+}

+ 51 - 0
src/main/java/com/jeeplus/modules/worksinglewage/dao/WorkSingleWageRecordDao.java

@@ -0,0 +1,51 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.worksinglewage.dao;
+
+import com.jeeplus.common.persistence.CrudDao;
+import com.jeeplus.common.persistence.annotation.MyBatisDao;
+import com.jeeplus.modules.worksinglewage.entity.WorkSingleWageRecord;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 通知通告记录DAO接口
+ * @author jeeplus
+ * @version 2014-05-16
+ */
+@MyBatisDao
+public interface WorkSingleWageRecordDao extends CrudDao<WorkSingleWageRecord> {
+
+	/**
+	 * 插入通知记录
+	 * @param workSingleWageRecordList
+	 * @return
+	 */
+	public int insertAll(List<WorkSingleWageRecord> workSingleWageRecordList);
+	/**
+	 * 插入通知记录
+	 * @param workSingleWageRecordOfficeList
+	 * @return
+	 */
+	public int insertOfficeAll(List<WorkSingleWageRecord> workSingleWageRecordOfficeList);
+
+	/**
+	 * 根据通知ID删除通知记录
+	 * @param workSingleWageRecord 通知ID
+	 * @return
+	 */
+	public int deleteByworkSingleWageId(WorkSingleWageRecord workSingleWageRecord);
+
+	public List<WorkSingleWageRecord> findUsers(WorkSingleWageRecord workSingleWageRecord);
+	public List<WorkSingleWageRecord> findOffices(WorkSingleWageRecord WworkSingleWageRecord);
+	public int findUserCount(@Param("id") String id, @Param("userId") String userId, @Param("branchOffice") String branchOffice);
+	public int findOfficeCount(@Param("id") String id, @Param("officeId") String officeId, @Param("branchOffice") String branchOffice);
+	public void deleteByWageId(@Param("wageId") String wageId);
+
+}
+
+   
+
+

+ 374 - 0
src/main/java/com/jeeplus/modules/worksinglewage/entity/WorkSingleWage.java

@@ -0,0 +1,374 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.worksinglewage.entity;
+
+import com.google.common.collect.Lists;
+import com.jeeplus.common.persistence.ActEntity;
+import com.jeeplus.common.utils.Collections3;
+import com.jeeplus.common.utils.IdGen;
+import com.jeeplus.modules.sys.entity.Area;
+import com.jeeplus.modules.sys.entity.Office;
+import javax.validation.constraints.NotNull;
+
+import com.jeeplus.common.persistence.DataEntity;
+import com.jeeplus.common.utils.excel.annotation.ExcelField;
+import com.jeeplus.modules.sys.entity.User;
+import com.jeeplus.modules.workclientinfo.entity.WorkClientAttachment;
+import com.jeeplus.modules.worksalaryitem.entity.WorkSalaryItem;
+import org.activiti.engine.history.HistoricProcessInstance;
+import org.activiti.engine.repository.ProcessDefinition;
+import org.activiti.engine.runtime.ProcessInstance;
+import org.activiti.engine.task.Task;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 单项工资Entity
+ * @author 杨帆
+ * @version 2018-09-26
+ */
+public class WorkSingleWage extends ActEntity<WorkSingleWage> {
+	
+	private static final long serialVersionUID = 1L;
+	private String companyId;		// company_id
+	private String status;		// 状态
+	private Office office;		// 部门id
+	private String name;		// 发放名称
+	private String month;		// 发放月份
+	private String wageId;		// 工资项
+	private Double money;		// 发放金额(元)
+	private String minmoney;		// 发放金额(元)
+	private String maxmoney;		// 发放金额(元)
+	private Integer branchCount;		// 分公司人数
+	private Integer grantCount;		// 发放人数
+	private String nowMonth;     //当月 上月
+	private Date startDate;
+	private Date endDate;
+	private WorkSalaryItem workSalaryItem;
+	private List<User> userList;
+	private List<Office> officeList;
+	private List<WorkSingleWageRecord> workSingleWageRecordList = Lists.newArrayList();
+	private List<WorkSingleWageRecord> workSingleWageRecordOfficeList = Lists.newArrayList();
+	private String view;
+	private String branchOffice;
+	private String processInstanceId;
+	private String home;
+
+	public WorkSingleWage() {
+		super();
+	}
+
+	public WorkSingleWage(String id){
+		super(id);
+	}
+	// 流程任务
+	private Task task;
+	private Map<String, Object> variables;
+	// 运行中的流程实例
+	private ProcessInstance processInstance;
+	// 历史的流程实例
+	private HistoricProcessInstance historicProcessInstance;
+	// 流程定义
+	private ProcessDefinition processDefinition;
+
+	private List<WorkClientAttachment> workAttachments = Lists.newArrayList();
+
+	public List<WorkClientAttachment> getWorkAttachments() {
+		return workAttachments;
+	}
+
+	public void setWorkAttachments(List<WorkClientAttachment> workAttachments) {
+		this.workAttachments = workAttachments;
+	}
+
+	@ExcelField(title="company_id", align=2, sort=1)
+	public String getCompanyId() {
+		return companyId;
+	}
+
+	public void setCompanyId(String companyId) {
+		this.companyId = companyId;
+	}
+	
+	@ExcelField(title="状态", align=2, sort=2)
+	public String getStatus() {
+		return status;
+	}
+
+	public void setStatus(String status) {
+		this.status = status;
+	}
+	
+	@ExcelField(title="部门id", fieldType=Office.class, value="office.name", align=2, sort=9)
+	public Office getOffice() {
+		return office;
+	}
+
+	public void setOffice(Office office) {
+		this.office = office;
+	}
+	
+	@ExcelField(title="发放名称", align=2, sort=10)
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+	
+	@ExcelField(title="发放月份", align=2, sort=11)
+	public String getMonth() {
+		return month;
+	}
+
+	public void setMonth(String month) {
+		this.month = month;
+	}
+	
+	@ExcelField(title="工资项", align=2, sort=12)
+	public String getWageId() {
+		return wageId;
+	}
+
+	public void setWageId(String wageId) {
+		this.wageId = wageId;
+	}
+	
+	@ExcelField(title="发放金额(元)", align=2, sort=13)
+	public Double getMoney() {
+		return money;
+	}
+
+	public void setMoney(Double money) {
+		this.money = money;
+	}
+	
+	@NotNull(message="分公司人数不能为空")
+	@ExcelField(title="分公司人数", align=2, sort=14)
+	public Integer getBranchCount() {
+		return branchCount;
+	}
+
+	public void setBranchCount(Integer branchCount) {
+		this.branchCount = branchCount;
+	}
+	
+	@NotNull(message="发放人数不能为空")
+	@ExcelField(title="发放人数", align=2, sort=15)
+	public Integer getGrantCount() {
+		return grantCount;
+	}
+
+	public void setGrantCount(Integer grantCount) {
+		this.grantCount = grantCount;
+	}
+
+	public Date getStartDate() {
+		return startDate;
+	}
+
+	public void setStartDate(Date startDate) {
+		this.startDate = startDate;
+	}
+
+	public Date getEndDate() {
+		return endDate;
+	}
+
+	public void setEndDate(Date endDate) {
+		this.endDate = endDate;
+	}
+
+	public WorkSalaryItem getWorkSalaryItem() {
+		return workSalaryItem;
+	}
+
+	public void setWorkSalaryItem(WorkSalaryItem workSalaryItem) {
+		this.workSalaryItem = workSalaryItem;
+	}
+
+	/**
+	 * 获取通知发送记录用户ID
+	 * @return
+	 */
+	public String getWorkSingleWageRecordIds() {
+		return Collections3.extractToString(workSingleWageRecordList, "user.id", ",") ;
+	}
+
+	/**
+	 * 设置通知发送记录用户ID
+	 * @return
+	 */
+	public void setWorkSingleWageRecordIds(List<User> users) {
+		this.workSingleWageRecordList = Lists.newArrayList();
+		if (users!=null && users.size()!=0) {
+			for (User user : users) {
+				if (user.getDelFlag().equals("0")) {
+					WorkSingleWageRecord entity = new WorkSingleWageRecord();
+					entity.setId(IdGen.uuid());
+					entity.setWorkSingleWage(this);
+					entity.setUser(user);
+					this.workSingleWageRecordList.add(entity);
+				}
+			}
+		}
+	}
+	/**
+	 * 设置通知发送记录用户ID
+	 * @return
+	 */
+	public void setWorkSingleWageRecordOffices(List<Office> offices) {
+		this.workSingleWageRecordOfficeList = Lists.newArrayList();
+		if (offices!=null && offices.size()!=0) {
+			for (Office office : offices) {
+				if (office.getDelFlag().equals("0")) {
+					WorkSingleWageRecord entity = new WorkSingleWageRecord();
+					entity.setId(IdGen.uuid());
+					entity.setWorkSingleWage(this);
+					entity.setOfficeId(office.getId());
+					this.workSingleWageRecordOfficeList.add(entity);
+				}
+			}
+		}
+	}
+
+	/**
+	 * 获取通知发送记录用户Name
+	 * @return
+	 */
+	public String getWorkSingleWageRecordNames() {
+		return Collections3.extractToString(workSingleWageRecordList, "user.name", ",") ;
+	}
+
+	public List<User> getUserList() {
+		return userList;
+	}
+
+	public void setUserList(List<User> userList) {
+		this.userList = userList;
+	}
+
+	public List<Office> getOfficeList() {
+		return officeList;
+	}
+
+	public void setOfficeList(List<Office> officeList) {
+		this.officeList = officeList;
+	}
+
+	public List<WorkSingleWageRecord> getWorkSingleWageRecordList() {
+		return workSingleWageRecordList;
+	}
+
+	public void setWorkSingleWageRecordList(List<WorkSingleWageRecord> workSingleWageRecordList) {
+		this.workSingleWageRecordList = workSingleWageRecordList;
+	}
+
+	public List<WorkSingleWageRecord> getWorkSingleWageRecordOfficeList() {
+		return workSingleWageRecordOfficeList;
+	}
+
+	public void setWorkSingleWageRecordOfficeList(List<WorkSingleWageRecord> workSingleWageRecordOfficeList) {
+		this.workSingleWageRecordOfficeList = workSingleWageRecordOfficeList;
+	}
+
+	public String getView() {
+		return view;
+	}
+
+	public void setView(String view) {
+		this.view = view;
+	}
+
+	public String getNowMonth() {
+		return nowMonth;
+	}
+
+	public void setNowMonth(String nowMonth) {
+		this.nowMonth = nowMonth;
+	}
+
+	public String getBranchOffice() {
+		return branchOffice;
+	}
+
+	public void setBranchOffice(String branchOffice) {
+		this.branchOffice = branchOffice;
+	}
+
+	public String getProcessInstanceId() {
+		return processInstanceId;
+	}
+
+	public void setProcessInstanceId(String processInstanceId) {
+		this.processInstanceId = processInstanceId;
+	}
+
+	public ProcessInstance getProcessInstance() {
+		return processInstance;
+	}
+
+	public void setProcessInstance(ProcessInstance processInstance) {
+		this.processInstance = processInstance;
+	}
+
+	public HistoricProcessInstance getHistoricProcessInstance() {
+		return historicProcessInstance;
+	}
+
+	public void setHistoricProcessInstance(HistoricProcessInstance historicProcessInstance) {
+		this.historicProcessInstance = historicProcessInstance;
+	}
+
+	public ProcessDefinition getProcessDefinition() {
+		return processDefinition;
+	}
+
+	public void setProcessDefinition(ProcessDefinition processDefinition) {
+		this.processDefinition = processDefinition;
+	}
+
+	public Task getTask() {
+		return task;
+	}
+
+	public void setTask(Task task) {
+		this.task = task;
+	}
+
+	public Map<String, Object> getVariables() {
+		return variables;
+	}
+
+	public void setVariables(Map<String, Object> variables) {
+		this.variables = variables;
+	}
+
+	public String getHome() {
+		return home;
+	}
+
+	public void setHome(String home) {
+		this.home = home;
+	}
+
+	public String getMinmoney() {
+		return minmoney;
+	}
+
+	public void setMinmoney(String minmoney) {
+		this.minmoney = minmoney;
+	}
+
+	public String getMaxmoney() {
+		return maxmoney;
+	}
+
+	public void setMaxmoney(String maxmoney) {
+		this.maxmoney = maxmoney;
+	}
+}

+ 63 - 0
src/main/java/com/jeeplus/modules/worksinglewage/entity/WorkSingleWageRecord.java

@@ -0,0 +1,63 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.worksinglewage.entity;
+
+import com.jeeplus.common.persistence.DataEntity;
+import com.jeeplus.modules.sys.entity.User;
+import com.jeeplus.modules.workattendance.entity.WorkAttendanceRule;
+
+
+/**
+ * 通知通告记录Entity
+ * @author jeeplus
+ * @version 2014-05-16
+ */
+public class WorkSingleWageRecord extends DataEntity<WorkSingleWageRecord> {
+
+	private static final long serialVersionUID = 1L;
+	private WorkSingleWage workSingleWage;		// 考勤规则id
+	private User user;		// 接受人
+	private String officeId; //部门id
+	private String officeName; //部门id
+
+	public WorkSingleWageRecord() {
+		super();
+	}
+
+	public WorkSingleWageRecord(String id){
+		super(id);
+	}
+
+	public User getUser() {
+		return user;
+	}
+
+	public void setUser(User user) {
+		this.user = user;
+	}
+	
+	public String getOfficeId() {
+		return officeId;
+	}
+
+	public void setOfficeId(String officeId) {
+		this.officeId = officeId;
+	}
+
+	public String getOfficeName() {
+		return officeName;
+	}
+
+	public void setOfficeName(String officeName) {
+		this.officeName = officeName;
+	}
+
+	public WorkSingleWage getWorkSingleWage() {
+		return workSingleWage;
+	}
+
+	public void setWorkSingleWage(WorkSingleWage workSingleWage) {
+		this.workSingleWage = workSingleWage;
+	}
+}

+ 683 - 0
src/main/java/com/jeeplus/modules/worksinglewage/service/WorkSingleWageService.java

@@ -0,0 +1,683 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.worksinglewage.service;
+
+import java.util.*;
+
+import com.google.common.collect.Maps;
+import com.jeeplus.common.utils.StringUtils;
+import com.jeeplus.modules.act.service.ActTaskService;
+import com.jeeplus.modules.act.utils.ActUtils;
+import com.jeeplus.modules.projectrecord.dao.WorkProjectUserDao;
+import com.jeeplus.modules.serialnum.service.SerialNumTplService;
+import com.jeeplus.modules.sys.entity.Office;
+import com.jeeplus.modules.sys.entity.User;
+import com.jeeplus.modules.sys.service.OfficeService;
+import com.jeeplus.modules.sys.utils.UserUtils;
+import com.jeeplus.modules.workactivity.dao.WorkActivityProcessDao;
+import com.jeeplus.modules.workactivity.entity.Activity;
+import com.jeeplus.modules.workactivity.entity.WorkActivityProcess;
+import com.jeeplus.modules.workactivity.service.ActivityService;
+import com.jeeplus.modules.workactivity.service.WorkActivityProcessService;
+import com.jeeplus.modules.workactivitymenu.entity.WorkActivityMenu;
+import com.jeeplus.modules.workactivitymenu.service.WorkActivityMenuService;
+import com.jeeplus.modules.workclientinfo.dao.WorkClientAttachmentDao;
+import com.jeeplus.modules.workprojectnotify.entity.WorkProjectNotify;
+import com.jeeplus.modules.workprojectnotify.service.WorkProjectNotifyService;
+import com.jeeplus.modules.workprojectnotify.util.UtilNotify;
+import com.jeeplus.modules.worksinglewage.dao.WorkSingleWageRecordDao;
+import com.jeeplus.modules.worksinglewage.entity.WorkSingleWageRecord;
+import com.jeeplus.modules.workstaff.dao.WorkStaffAchivesDao;
+import com.jeeplus.modules.workstaff.entity.WorkStaffBasicInfo;
+import org.activiti.engine.*;
+import org.activiti.engine.runtime.ProcessInstance;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.jeeplus.common.persistence.Page;
+import com.jeeplus.common.service.CrudService;
+import com.jeeplus.modules.worksinglewage.entity.WorkSingleWage;
+import com.jeeplus.modules.worksinglewage.dao.WorkSingleWageDao;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+/**
+ * 单项工资Service
+ * @author 杨帆
+ * @version 2018-09-26
+ */
+@Service
+@Transactional(readOnly = true)
+public class WorkSingleWageService extends CrudService<WorkSingleWageDao, WorkSingleWage> {
+	@Autowired
+	private WorkSingleWageRecordDao workSingleWageRecordDao;
+	@Autowired
+	private WorkSingleWageDao workSingleWageDao;
+	@Autowired
+	private RuntimeService runtimeService;
+	@Autowired
+	protected TaskService taskService;
+	@Autowired
+	protected HistoryService historyService;
+	@Autowired
+	protected RepositoryService repositoryService;
+	@Autowired
+	private IdentityService identityService;
+	@Autowired
+	private ActTaskService actTaskService;
+
+	@Autowired
+	private WorkProjectNotifyService workProjectNotifyService;
+	@Autowired
+	private WorkActivityMenuService workActivityMenuService;
+	@Autowired
+	private WorkActivityProcessService workActivityProcessService;
+	@Autowired
+	private ActivityService activityService;
+	@Autowired
+	private WorkActivityProcessDao workActivityProcessDao;
+	@Autowired
+	private OfficeService officeService;
+	@Autowired
+	private WorkStaffAchivesDao workStaffAchivesDao;
+
+	public WorkSingleWage get(String id) {
+		WorkSingleWage workSingleWage = super.get(id);
+		WorkSingleWageRecord workSingleWageRecord = new WorkSingleWageRecord();
+		workSingleWageRecord.setWorkSingleWage(workSingleWage);
+		List<WorkSingleWageRecord> workAttendanceRuleRecordList = workSingleWageRecordDao.findUsers(workSingleWageRecord);
+		List<WorkSingleWageRecord> workAttendanceRuleRecordOfficeList = workSingleWageRecordDao.findOffices(workSingleWageRecord);
+		if (workAttendanceRuleRecordList!=null &&workAttendanceRuleRecordList.size()!=0){
+			List<User> users = new ArrayList<>();
+			for(WorkSingleWageRecord wageRecord:workAttendanceRuleRecordList){
+				users.add(wageRecord.getUser());
+			}
+			workSingleWage.setUserList(users);
+		}
+		if (workAttendanceRuleRecordOfficeList!=null &&workAttendanceRuleRecordOfficeList.size()!=0){
+			List<Office> offices = new ArrayList<>();
+			for(WorkSingleWageRecord wageRecord:workAttendanceRuleRecordOfficeList){
+				Office office = new Office(wageRecord.getOfficeId());
+				office.setName(wageRecord.getOfficeName());
+				offices.add(office);
+			}
+			workSingleWage.setOfficeList(offices);
+		}
+		return workSingleWage;
+	}
+	
+	public List<WorkSingleWage> findList(WorkSingleWage workSingleWage) {
+		return super.findList(workSingleWage);
+	}
+	
+	public Page<WorkSingleWage> findPage(Page<WorkSingleWage> page, WorkSingleWage workSingleWage) {
+		if (StringUtils.isBlank(workSingleWage.getBranchOffice())){
+			workSingleWage.setBranchOffice(UserUtils.getSelectBranchOffice());
+		}
+		page.setList(findList(workSingleWage));
+		return page;
+	}
+	
+	@Transactional(readOnly = false)
+	public void save(WorkSingleWage workSingleWage) {
+		if (StringUtils.isBlank(workSingleWage.getCompanyId())){
+			workSingleWage.setCompanyId(UserUtils.getSelectCompany().getId());
+		}
+		if (StringUtils.isBlank(workSingleWage.getBranchOffice())){
+			workSingleWage.setBranchOffice(UserUtils.getSelectBranchOffice());
+		}
+		if (workSingleWage.getOffice()==null || StringUtils.isBlank(workSingleWage.getOffice().getId())){
+			workSingleWage.setOffice(UserUtils.getSelectOffice());
+		}
+		List<User> users = workSingleWage.getUserList();
+		List<Office> offices = workSingleWage.getOfficeList();
+		workSingleWage.setWorkSingleWageRecordIds(users);
+		workSingleWage.setWorkSingleWageRecordOffices(offices);
+		WorkSingleWageRecord workSingleWageRecord = new WorkSingleWageRecord();
+		workSingleWageRecord.setWorkSingleWage(workSingleWage);
+		Set<String> set = new HashSet<>();
+		// 更新发送接受人记录
+		workSingleWageRecordDao.deleteByworkSingleWageId(workSingleWageRecord);
+		if (workSingleWage.getWorkSingleWageRecordList()!=null && workSingleWage.getWorkSingleWageRecordList().size() > 0){
+			for (WorkSingleWageRecord wageRecord : workSingleWage.getWorkSingleWageRecordList()){
+				set.add(wageRecord.getUser().getId());
+			}
+			workSingleWageRecordDao.insertAll(workSingleWage.getWorkSingleWageRecordList());
+		}
+		if (workSingleWage.getWorkSingleWageRecordOfficeList()!=null && workSingleWage.getWorkSingleWageRecordOfficeList().size() > 0){
+			workSingleWageRecordDao.insertOfficeAll(workSingleWage.getWorkSingleWageRecordOfficeList());
+			for (WorkSingleWageRecord wageRecord : workSingleWage.getWorkSingleWageRecordList()){
+				String officeId = wageRecord.getOfficeId();
+				WorkStaffBasicInfo workStaffBasicInfo = new WorkStaffBasicInfo();
+				workStaffBasicInfo.setOffice(new Office(officeId));
+				List<WorkStaffBasicInfo> workStaffBasicInfos = workStaffAchivesDao.getByOffice(workStaffBasicInfo);
+				if (workStaffBasicInfos!=null && workStaffBasicInfos.size()!=0){
+					for (WorkStaffBasicInfo staffBasicInfo:workStaffBasicInfos){
+						set.add(staffBasicInfo.getUserId());
+					}
+				}
+			}
+		}
+		workSingleWage.setGrantCount(set.size());
+		super.save(workSingleWage);
+
+	}
+
+	/**
+	 * 提交存储
+	 * @param workSingleWage
+	 * @param variables
+	 */
+	@Transactional(readOnly = false)
+	public String save(WorkSingleWage workSingleWage, Map<String, Object> variables, String processInstanceId) {
+		User user = UserUtils.getUser();
+		this.save(workSingleWage);
+		String str =  "发放名称:"+workSingleWage.getName()+",发放月份:"+workSingleWage.getMonth()+",发放金额:"+workSingleWage.getMoney()+",发放人数:"+workSingleWage.getGrantCount()+",分公司人数:"+workSingleWage.getBranchCount();
+		Office office = officeService.get(workSingleWage.getOffice().getId());
+		String title = "发放名称:"+workSingleWage.getName();
+		// 用来设置启动流程的人员ID,引擎会自动把用户ID保存到activiti:initiator中
+		identityService.setAuthenticatedUserId(user.getId());
+		// 启动流程
+		String businessKey = workSingleWage.getId().toString();
+		WorkActivityMenu workActivityMenu = workActivityMenuService.findByParentAndOffice("dbxql3125f1f194c8lz88a9miiii75090499", office);
+		// 启动流程
+		String processType = workActivityMenu.getProcessType();
+		StringBuffer buffer = new StringBuffer();
+		Activity activity = new Activity();
+		WorkProjectNotify workProjectNotify = UtilNotify
+				.saveNotify(workSingleWage.getId(),
+						null,
+						workSingleWage.getCompanyId(),
+						title,
+						str,
+						"85",
+						"0",
+						"待审批",
+						""
+				);
+		List<User> users = new ArrayList<>();
+		List<User> bmzrs = UserUtils.getByRoleActivityEnname("bmzr",2,office.getId(),"28",workSingleWage.getCreateBy());
+		if (StringUtils.isNotBlank(workActivityMenu.getId())) {
+			workProjectNotify.setNotifyRole("");
+			workActivityMenu = workActivityMenuService.get(workActivityMenu.getId());
+			List<Activity> activities = workActivityMenu.getActivities();
+			for (Activity a : activities) {
+				String encount = a.getEncount();
+				String enlist = a.getEnlist();
+				if (a.getRole()!=null && StringUtils.isNotBlank(a.getRole().getEnname())){
+					List enusers = UserUtils.getByRoleActivityEnnames(a.getRole().getEnname(),office.getId(),"28",workSingleWage.getCreateBy());
+					if (enusers.size()==0){
+						workSingleWage.setStatus("1");
+						super.save(workSingleWage);
+						return "流程审批人不能为空,角色"+a.getRole().getName()+"下无用户,请联系管理员!";
+					}
+					variables.put(enlist, enusers);
+					variables.put(encount, enusers.size());
+				}
+				if (a.getDelFlag().equals("0") && a.getCount() == 1) {
+					activity = a;
+				}
+			}
+			buffer.append(activity.getRole().getEnname());
+			if (activity != null && StringUtils.isNotBlank(activity.getId())) {
+				//角色审批
+				if (StringUtils.isNotBlank(activity.getRole().getEnname())) {
+					users = UserUtils.getByRoleActivityEnnames(activity.getRole().getEnname(),office.getId(),"28",workSingleWage.getCreateBy());
+				}
+				//人员审批
+				if (StringUtils.isNotBlank(activity.getUser().getId())) {
+					users.add(activity.getUser());
+				}
+			}
+			workProjectNotify.setId("");
+		} else {
+			variables.put("bmzrList", bmzrs);
+			if (bmzrs.size()==0 ){
+				workSingleWage.setStatus("1");
+				super.save(workSingleWage);
+			}
+			if (bmzrs.size()==0){
+				return "流程审批人不能为空,角色部门负责人下无用户,请联系管理员!";
+			}
+			variables.put("bmzrcount",bmzrs.size());
+			processType = "workwage";
+			users.addAll(bmzrs);
+		}
+		for (User u : users){
+			workProjectNotify.setUser(u);
+			workProjectNotify.setId("");
+			workProjectNotify.setNotifyRole("部门负责人审批");
+			workProjectNotifyService
+					.save(workProjectNotify);
+			Map<String,Object> extras = new HashMap<>();
+			extras.put("type","7001");
+			extras.put("id",workProjectNotify.getId());
+			extras.put("procDefKey","85");
+			UserUtils.pushInfoToApp(title,str,extras,u.getId());
+			UserUtils.pushIm(u.getId(),str);
+		}
+		variables.put("type", processType);
+		variables.put("busId", businessKey);
+		variables.put("title", title);//设置标题;
+
+		ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(processType, businessKey, variables);
+		workSingleWage.setProcessInstance(processInstance);
+		if (StringUtils.isNotBlank(processInstanceId)) {
+			workActivityProcessService.updateProcessInstanceId(processInstance.getId(),processInstanceId);
+			workActivityProcessService.deleteProcessInstanceId(processInstanceId);
+			workActivityProcessService.deleteProcessIdAuditUsers(processInstanceId);
+		}
+		// 更新流程实例ID
+		workSingleWage.setProcessInstanceId(processInstance.getId());
+		workSingleWageDao.updateProcessInstanceId(workSingleWage);
+		List<Activity> list = workActivityMenu.getActivities();
+		if (list != null && list.size() != 0) {
+			workActivityProcessService.saveList(list, processInstance.getId());
+		} else {
+			WorkActivityProcess workActivityProcess = new WorkActivityProcess();
+			workActivityProcess.setProcessKey("workwage");
+			workActivityProcess.setCount(1);
+			workActivityProcess.setProcessInstanceId(processInstance.getId());
+			workActivityProcess.setIsApproval("0");
+			workActivityProcessService.save(workActivityProcess);
+			workActivityProcessService.insertAuditsByType(bmzrs,processInstance.getId(),1,1);
+		}
+		logger.debug("start process of {key={}, bkey={}, pid={}, variables={}}", new Object[]{
+				"workwage", businessKey, processInstance.getId(), variables});
+		return "";
+	}
+
+	/**
+	 * 审核流程
+	 * @param workSingleWage
+	 */
+	@Transactional(readOnly = false)
+	public String auditSave(WorkSingleWage workSingleWage,List<User> auditUsers) {
+		String userName = UserUtils.get(workSingleWage.getCreateBy().getId()).getName();
+		String str =  "发放名称:"+workSingleWage.getName()+",发放月份:"+workSingleWage.getMonth()+",发放金额:"+workSingleWage.getMoney()+",发放人数:"+workSingleWage.getGrantCount()+",分公司人数:"+workSingleWage.getBranchCount();
+		Office office = officeService.get(workSingleWage.getOffice().getId());
+		String title = "发放名称:"+workSingleWage.getName();
+		// 对不同环节的业务逻辑进行操作
+		String taskDefKey = workSingleWage.getAct().getTaskDefKey();
+		if (!"modifyApply".equals(taskDefKey) && !taskDefKey.contains("audit") ) {
+			actTaskService.claim(workSingleWage.getAct().getTaskId(), UserUtils.getUser().getId());
+		}else{
+			workSingleWage.getAct().setFlag("yes");
+			save(workSingleWage);
+		}
+		String comment = "";
+		if (workSingleWage.getStatus().equals("4")){
+			comment = ("yes".equals(workSingleWage.getAct().getFlag())?"[重新申请] ":"[已撤销] ");
+		}else {
+			comment = ("yes".equals(workSingleWage.getAct().getFlag())?"[同意] ":"[驳回] ")+workSingleWage.getAct().getComment();
+		}
+		//yes 的时候状态为审核通过 否则为未通过
+		//1 审核中 2 未通过
+		workSingleWage.setStatus(("yes".equals(workSingleWage.getAct().getFlag()) ? "2" : "4"));
+		Map<String, Object> vars = Maps.newHashMap();
+		//业务逻辑对应的条件表达式
+		String exp = "";
+		String taskCount = "";
+		String notifyRole = "";
+		int key = 0;
+		String enname = "";
+		List<Activity> activitieList = activityService.getByProcessInstanceId(workSingleWage.getProcessInstanceId());
+		WorkActivityMenu workActivityMenu = new WorkActivityMenu();
+		if (activitieList != null && activitieList.size() != 0) {
+			workActivityMenu.setProcessType(activitieList.get(0).getProcessKey());
+			workActivityMenu.setActivities(activitieList);
+		}
+
+		WorkActivityProcess workActivityProcess = new WorkActivityProcess();
+		WorkActivityProcess selectProcess = new WorkActivityProcess();
+		selectProcess.setProcessInstanceId(workSingleWage.getProcessInstanceId());
+		List<WorkActivityProcess> workActivityProcesses = workActivityProcessService.findList(selectProcess);
+		List<Activity> activities = workActivityMenu.getActivities();
+		if (StringUtils.isNotBlank(workActivityMenu.getProcessType()) && !workActivityMenu.getProcessType().equals("workwage")) {
+			key = 1;
+			for (int i = 0; i < workActivityProcesses.size(); i++) {
+				WorkActivityProcess activityProcess = workActivityProcesses.get(i);
+				if (taskDefKey.equals(activityProcess.getActivityTask()) && !taskDefKey.equals("modifyApply")) {
+					taskCount = activityProcess.getCount()+"";
+					workActivityProcess = activityProcess;
+					if (!workActivityProcess.getIsApproval().equals("0")) {
+						workActivityProcess.setId("");
+					}
+					exp = "pass";
+					if (!"yes".equals(workSingleWage.getAct().getFlag())) {
+						workSingleWage.setStatus("4");
+						workActivityProcess.setIsApproval("2");
+						String returnBack = "-1";
+						for (Activity activity : activities) {
+							if (activity.getCount() == activityProcess.getCount()) {
+								returnBack = activity.getReturnBack();
+								notifyRole = activity.getName();
+								break;
+							}
+						}
+						if (returnBack.equals("0")) {
+							workActivityProcess.setId("");
+						}
+
+					} else {
+						workActivityProcess.setIsApproval("1");
+					}
+				}else if(taskDefKey.equals("modifyApply")){
+					notifyRole = "调整审批";
+					taskCount = "0";
+					exp = "pass";
+					workActivityProcess.setId("");
+					workActivityProcess.setCount(0);
+					if (!"yes".equals(workSingleWage.getAct().getFlag())) {
+						workSingleWage.setStatus("3");
+						workActivityProcess.setIsApproval("2");
+					} else {
+						workActivityProcess.setIsApproval("1");
+					}
+					break;
+				}
+			}
+		} else {
+			workActivityMenu.setProcessType("workwage");
+			for (int i = 0; i < workActivityProcesses.size(); i++) {
+				WorkActivityProcess activityProcess = workActivityProcesses.get(i);
+				String count = activityProcess.getCount() + "";
+				workActivityProcess = activityProcess;
+				if (!workActivityProcess.getIsApproval().equals("0")) {
+					workActivityProcess.setId("");
+				}
+				// 审核环节
+				if ("bmzr".equals(taskDefKey) && count.contains("1")) {
+					taskCount = "1";
+					exp = "pass";
+					if ("yes".equals(workSingleWage.getAct().getFlag())) {
+						notifyRole = "审批通过";
+						workActivityProcess.setIsApproval("1");
+					} else {
+						notifyRole = "调整申请";
+						workActivityProcess.setIsApproval("2");
+					}
+					break;
+				}else if ("modifyApply".equals(taskDefKey)&& count.contains("0")) {
+					taskCount = "0";
+					notifyRole = "部门负责人审批";
+					exp = "pass";
+					workActivityProcess.setCount(0);
+					enname = "bmzr";
+					if (!"yes".equals(workSingleWage.getAct().getFlag())) {
+						workSingleWage.setStatus("3");
+					}
+					break;
+				} else if ("apply_end".equals(taskDefKey)) {
+				}
+
+			}
+		}
+		// 设置意见
+		workSingleWage.getAct().setComment(("yes".equals(workSingleWage.getAct().getFlag()) ? "[同意] " : "[驳回] ") + workSingleWage.getAct().getComment());
+		workSingleWage.preUpdate();
+		// 提交流程任务
+		vars.put(exp, "yes".equals(workSingleWage.getAct().getFlag()) ? true : false);
+		vars.put("passs", true);
+		workActivityProcessService.updateProcess(workActivityProcess,workActivityMenu,key,taskCount,workSingleWage.getProcessInstanceId(),taskDefKey,"modifyApply",workSingleWage.getAct().getFlag(),comment, activities);
+		// 提交流程任务
+		actTaskService.complete(workSingleWage.getAct().getTaskId(), workSingleWage.getAct().getProcInsId(), workSingleWage.getAct().getComment(), vars);
+		boolean state = actTaskService.isProcessEnd(workSingleWage.getAct().getProcInsId());
+		List<User> users = new ArrayList<>();
+		List<User> userList = new ArrayList<>();
+		if (!state) {
+			users.add(workSingleWage.getCreateBy());
+			if ("yes".equals(workSingleWage.getAct().getFlag())) {
+				workSingleWage.setStatus("5");
+				WorkProjectNotify notify = new WorkProjectNotify();
+				notify.setNotifyId(workSingleWage.getId());
+				userList = workProjectNotifyService.readByNotifyId(notify);
+				workProjectNotifyService
+						.save(UtilNotify
+								.saveNotify(workSingleWage.getId(),
+										workSingleWage.getCreateBy(),
+										workSingleWage.getCompanyId(),
+										title,
+										str,
+										"85",
+										"0",
+										"待通知",
+										notifyRole));
+
+			} else {
+				WorkProjectNotify notify = new WorkProjectNotify();
+				notify.setNotifyId(workSingleWage.getId());
+				userList = workProjectNotifyService.readByNotifyId(notify);
+				if (StringUtils.isNotBlank(workSingleWage.getStatus()) && !workSingleWage.getStatus().equals("3")){
+					workSingleWage.setStatus("4");
+					workProjectNotifyService
+							.save(UtilNotify
+									.saveNotify(workSingleWage.getId(),
+											workSingleWage.getCreateBy(),
+											workSingleWage.getCompanyId(),
+											title,
+											str,
+											"85",
+											"0",
+											"待通知",
+											notifyRole));
+				}
+			}
+			workActivityProcessService.deleteProcessIdAuditUsers(workSingleWage.getProcessInstanceId());
+		} else {
+			if (StringUtils.isNotBlank(workActivityMenu.getProcessType()) && !workActivityMenu.getProcessType().equals("workwage")) {
+				WorkProjectNotify notify = new WorkProjectNotify();
+				notify.setNotifyId(workSingleWage.getId());
+				userList = workProjectNotifyService.readByNotifyId(notify);
+				WorkProjectNotify workProjectNotify = UtilNotify
+						.saveNotify(workSingleWage.getId(),
+								new User(),
+								workSingleWage.getCompanyId(),
+								title,
+								str,
+								"85",
+								"0",
+								"待审批",
+								notifyRole);
+				List<WorkProjectNotify> workProjectNotifys = activityService.getByFlagAndTaskDefKeyList(
+						activities,
+						workProjectNotify,
+						taskDefKey,
+						workSingleWage.getAct().getFlag(),
+						taskCount,
+						workSingleWage.getCreateBy(),
+						workSingleWage.getOffice().getId(),
+						"28");
+				for (WorkProjectNotify workProjectNotify1:workProjectNotifys){
+					users.add(workProjectNotify1.getUser());
+					workProjectNotify1.setId("");
+					workProjectNotify1.setIsNewRecord(false);
+					workProjectNotifyService
+							.save(workProjectNotify1);
+					if (!"modifyApply".equals(taskDefKey)){
+						Map<String,Object> extras = new HashMap<>();
+						if ("cw".equals(taskDefKey) || "cn".equals(taskDefKey) ){
+							extras.put("type","7001");
+						}else {
+							extras.put("type","7002");
+						}
+						extras.put("id",workProjectNotify.getId());
+						extras.put("procDefKey","85");
+						UserUtils.pushInfoToApp(title,str,extras,workProjectNotify1.getUser().getId());
+
+					}
+				}
+
+			} else {
+				if (!"yes".equals(workSingleWage.getAct().getFlag())) {
+					WorkProjectNotify notify = new WorkProjectNotify();
+					notify.setNotifyId(workSingleWage.getId());
+					userList = workProjectNotifyService.readByNotifyId(notify);
+					//users.addAll(userList);
+					workProjectNotifyService
+							.save(UtilNotify
+									.saveNotify(workSingleWage.getId(),
+											workSingleWage.getCreateBy(),
+											workSingleWage.getCompanyId(),
+											title,
+											str,
+											"85",
+											"0",
+											"重新申请",
+											notifyRole));
+					users.add( workSingleWage.getCreateBy());
+				} else {
+					if (StringUtils.isNotBlank(enname)) {
+						WorkProjectNotify notify = new WorkProjectNotify();
+						notify.setNotifyId(workSingleWage.getId());
+						userList = workProjectNotifyService.readByNotifyId(notify);
+						//users.addAll(userList1);
+						WorkProjectNotify workProjectNotify = UtilNotify
+								.saveNotify(workSingleWage.getId(),
+										new User(),
+										workSingleWage.getCompanyId(),
+										title,
+										str,
+										"85",
+										"0",
+										"待审批",
+										notifyRole);
+						users.addAll(auditUsers);
+						for (User user1:auditUsers){
+							workProjectNotify.setId("");
+							workProjectNotify.setUser(user1);
+							workProjectNotify.setIsNewRecord(false);
+							workProjectNotifyService
+									.save(workProjectNotify);
+							if (!"modifyApply".equals(taskDefKey)){
+								Map<String,Object> extras = new HashMap<>();
+								extras.put("type","7001");
+								extras.put("id",workProjectNotify.getId());
+								extras.put("procDefKey","85");
+								UserUtils.pushInfoToApp(title,str,extras,user1.getId());
+
+							}
+						}
+					}else {
+						WorkProjectNotify notify = new WorkProjectNotify();
+						notify.setNotifyId(workSingleWage.getId());
+						userList = workProjectNotifyService.readByNotifyId(notify);
+						users.addAll(userList);
+						users.add(workSingleWage.getCreateBy());
+						workProjectNotifyService
+								.save(UtilNotify
+										.saveNotify(workSingleWage.getId(),
+												workSingleWage.getCreateBy(),
+												workSingleWage.getCompanyId(),
+												title,
+												str,
+												"85",
+												"0",
+												"重新申请",
+												notifyRole));
+					}
+				}
+			}
+		}
+		if (users!=null && users.size()!=0) {
+			for (User u : users) {
+				UserUtils.pushIm(u.getId(),str);
+			}
+		}
+		if (userList!=null && userList.size()!=0) {
+			for (User u : userList) {
+				UserUtils.pushMeIm(u.getId());
+			}
+		}
+
+		workSingleWageDao.update(workSingleWage);
+		return "保存审核意见成功!";
+	}
+	
+	@Transactional(readOnly = false)
+	public void delete(WorkSingleWage workSingleWage) {
+		WorkProjectNotify notify = new WorkProjectNotify();
+		notify.setNotifyId(workSingleWage.getId());
+		List<User> users = workProjectNotifyService.readByNotifyId(notify);
+		if (users!=null && users.size()!=0){
+			for (User user:users){
+				UserUtils.pushMeIm(user.getId());
+			}
+		}
+		workSingleWageRecordDao.deleteByWageId(workSingleWage.getId());
+		super.delete(workSingleWage);
+	}
+	/**
+	 * 读取单个实体流程
+	 * @return
+	 */
+	@RequestMapping(value = "getProcessOne")
+	public String getProcessOne(WorkSingleWage workSingleWage,Model model) {
+		model.addAttribute("processInstanceId", workSingleWage.getProcessInstanceId());
+		return "modules/workworkwage/workworkwageTrack";
+	}
+	/**
+	 * 单笔工资项作废:强制撤销
+	 * @param workSingleWage
+	 */
+	@Transactional(readOnly = false)
+	public void cancelInvalidate(WorkSingleWage workSingleWage) {
+		String invalidateProcessInstanceId = workSingleWage.getProcessInstanceId();
+		try {
+			//将流程图中尚未走到的task的流程追踪信息逻辑删除,添加一条"撤销"流程追踪信息
+			WorkActivityProcess process = new WorkActivityProcess();
+			process.setProcessInstanceId(workSingleWage.getProcessInstanceId());
+			process.setIsApproval("0");
+			//List<WorkActivityProcess> processList1 = workActivityProcessService.findByProcInsId(process);
+			WorkActivityProcess workActivityProcess = new WorkActivityProcess();
+			workActivityProcess.setProcessInstanceId(workSingleWage.getProcessInstanceId());
+			List<WorkActivityProcess> processList = workActivityProcessService.findList(workActivityProcess);
+			WorkProjectNotify notify = new WorkProjectNotify();
+			notify.setNotifyId(workSingleWage.getId());
+			List<User> userList = workProjectNotifyService.readByNotifyId(notify);
+			if (userList!=null && userList.size()!=0) {
+				for (User u : userList) {
+					User user = UserUtils.get(u.getId());
+					UserUtils.pushMeIm(user.getId());
+				}
+			}
+			if(processList!=null && processList.size()>0){
+				for (int i =0;i<processList.size();i++) {
+					WorkActivityProcess p = processList.get(i);
+					if(StringUtils.isNotBlank(p.getIsApproval()) && "0".equals(p.getIsApproval())){
+						p.setIsApproval("-1");
+						p.setDelFlag("1");
+						workActivityProcessDao.updateDelFlagAndIsApproval(p);
+					}
+				}
+				WorkActivityProcess pro = new WorkActivityProcess();
+				pro.setId("");
+				pro.preInsert();
+				pro.setDelFlag("0");
+				pro.setRemarks("[强制撤销]");
+				pro.setIsApproval("1");
+				pro.setProcessKey(processList.get(0).getProcessKey());
+				pro.setProcessInstanceId(processList.get(0).getProcessInstanceId());
+				pro.setCount(0);
+				workActivityProcessDao.insert(pro);
+			}
+
+			//结束该流程,设为"撤销"状态
+			actTaskService.endProcessInstance(invalidateProcessInstanceId,"单笔工资项-强制撤销");
+			workSingleWage.setStatus("3");
+			workSingleWage.preUpdate();
+			dao.update(workSingleWage);
+		}catch (ActivitiObjectNotFoundException e){
+			System.err.println("撤销单笔工资项作废异常,因为这个流程已不存在!");
+			e.printStackTrace();
+		}
+		catch (Exception e) {
+			e.printStackTrace();
+		}
+
+	}
+
+
+}

+ 399 - 0
src/main/java/com/jeeplus/modules/worksinglewage/web/WorkSingleWageController.java

@@ -0,0 +1,399 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.worksinglewage.web;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.validation.ConstraintViolationException;
+
+import com.google.common.collect.Maps;
+import com.jeeplus.modules.act.entity.Act;
+import com.jeeplus.modules.act.service.ActTaskService;
+import com.jeeplus.modules.sys.entity.Office;
+import com.jeeplus.modules.sys.entity.User;
+import com.jeeplus.modules.sys.utils.UserUtils;
+import com.jeeplus.modules.worksalaryitem.entity.WorkSalaryItem;
+import com.jeeplus.modules.worksalaryitem.service.WorkSalaryItemService;
+import com.jeeplus.modules.workstaff.dao.WorkStaffAchivesDao;
+import com.jeeplus.modules.workstaff.entity.WorkStaffBasicInfo;
+import org.activiti.engine.runtime.ProcessInstance;
+import org.activiti.engine.task.Task;
+import org.apache.shiro.authz.annotation.Logical;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.servlet.mvc.support.RedirectAttributes;
+
+import com.google.common.collect.Lists;
+import com.jeeplus.common.utils.DateUtils;
+import com.jeeplus.common.utils.MyBeanUtils;
+import com.jeeplus.common.config.Global;
+import com.jeeplus.common.persistence.Page;
+import com.jeeplus.common.web.BaseController;
+import com.jeeplus.common.utils.StringUtils;
+import com.jeeplus.common.utils.excel.ExportExcel;
+import com.jeeplus.common.utils.excel.ImportExcel;
+import com.jeeplus.modules.worksinglewage.entity.WorkSingleWage;
+import com.jeeplus.modules.worksinglewage.service.WorkSingleWageService;
+
+/**
+ * 单笔工资项Controller
+ * @author 杨帆
+ * @version 2018-09-26
+ */
+@Controller
+@RequestMapping(value = "${adminPath}/worksinglewage/workSingleWage")
+public class WorkSingleWageController extends BaseController {
+
+	@Autowired
+	private WorkSingleWageService workSingleWageService;
+	@Autowired
+	private WorkSalaryItemService workSalaryItemService;
+	@Autowired
+	private WorkStaffAchivesDao workStaffAchivesDao;
+	@Autowired
+	private HttpServletRequest request;
+	@Autowired
+	private ActTaskService actTaskService;
+	
+	@ModelAttribute
+	public WorkSingleWage get(@RequestParam(required=false) String id) {
+		WorkSingleWage entity = null;
+		if (StringUtils.isNotBlank(id)){
+			entity = workSingleWageService.get(id);
+		}
+		if (entity == null){
+			entity = new WorkSingleWage();
+		}
+		return entity;
+	}
+	
+	/**
+	 * 单笔工资项列表页面
+	 */
+	@RequiresPermissions("worksinglewage:workSingleWage:list")
+	@RequestMapping(value = {"list", ""})
+	public String list(WorkSingleWage workSingleWage, HttpServletRequest request, HttpServletResponse response, Model model) {
+		if (StringUtils.isNotBlank(workSingleWage.getMinmoney() )|| StringUtils.isNotBlank(workSingleWage.getMaxmoney())){
+			try {
+				Double minMoney = Double.parseDouble(workSingleWage.getMinmoney());
+				Double maxMoney = Double.parseDouble(workSingleWage.getMaxmoney());
+			}catch (Exception e){
+				Page<WorkSingleWage> page = workSingleWageService.findPage(new Page<WorkSingleWage>(request, response), workSingleWage);
+				model.addAttribute("page", page);
+				model.addAttribute("message", "发放金额请输入数字");
+				return "modules/worksinglewage/workSingleWageList";
+			}
+		}
+		Page<WorkSingleWage> page = workSingleWageService.findPage(new Page<WorkSingleWage>(request, response), workSingleWage); 
+		model.addAttribute("page", page);
+		return "modules/worksinglewage/workSingleWageList";
+	}
+
+	/**
+	 * 查看,增加,编辑单笔工资项表单页面
+	 */
+	@RequiresPermissions(value={"worksinglewage:workSingleWage:view","worksinglewage:workSingleWage:add","worksinglewage:workSingleWage:edit"},logical=Logical.OR)
+	@RequestMapping(value = "form")
+	public String form(WorkSingleWage workSingleWage, Model model) {
+		Map<String,String> map = StringUtils.getMonth();
+		if (workSingleWage==null || StringUtils.isBlank(workSingleWage.getId())){
+			workSingleWage.setNowMonth("1");
+			workSingleWage.setMonth(map.get(workSingleWage.getNowMonth()));
+			workSingleWage.setCreateBy(UserUtils.getUser());
+			workSingleWage.setCreateDate(new Date());
+			WorkStaffBasicInfo workStaffBasicInfo = new WorkStaffBasicInfo();
+			workStaffBasicInfo.setBranchOffice(new Office(UserUtils.getSelectBranchOffice()));
+			workSingleWage.setBranchCount(workStaffAchivesDao.getByBranchCompany(workStaffBasicInfo));
+			workSingleWage.setGrantCount(0);
+		}
+		String view = "workSingleWageForm";
+		String tabId = request.getParameter("tabId");
+		if("1".equals(tabId)){
+			view = "workSingleWageView";
+		}else if("3".equals(tabId)){
+			ProcessInstance processInstance = actTaskService.getProcIns(workSingleWage.getProcessInstanceId());
+			if (processInstance!=null) {
+				Task taskInfok = actTaskService.getCurrentTaskInfo(processInstance);
+				Act act = new Act();
+				act.setTaskId(taskInfok.getId());
+				act.setTaskName(taskInfok.getName());
+				act.setTaskDefKey(taskInfok.getTaskDefinitionKey());
+				act.setProcDefId(taskInfok.getProcessDefinitionId());
+				act.setProcInsId(taskInfok.getProcessInstanceId());
+				act.setTask(taskInfok);
+				workSingleWage.setAct(act);
+				view = "workSingleWageModifyApply";
+			}
+		}
+		// 环节编号
+		String taskDefKey = workSingleWage.getAct().getTaskDefKey();
+		if (StringUtils.isNotBlank(taskDefKey) && "".equals(taskDefKey)){
+			view = "workSingleWageAudit";
+		}
+		model.addAttribute("workSingleWage", workSingleWage);
+		model.addAttribute("nowm", map.get("1"));
+		model.addAttribute("oldm", map.get("2"));
+		return "modules/worksinglewage/"+view;
+	}
+
+	/**
+	 * 保存单笔工资项
+	 */
+	@RequiresPermissions(value={"worksinglewage:workSingleWage:add","worksinglewage:workSingleWage:edit"},logical=Logical.OR)
+	@RequestMapping(value = "save")
+	public String save(WorkSingleWage workSingleWage, Model model, RedirectAttributes redirectAttributes) throws Exception{
+		if (!beanValidator(model, workSingleWage)){
+			return form(workSingleWage, model);
+		}
+		String processInstanceId ="";
+		User user = workSingleWage.getCreateBy();
+		String sta = workSingleWage.getStatus();
+		if(user!=null && !UserUtils.getUser().getId().equals(user.getId()) && StringUtils.isNotBlank(user.getId())){
+			addMessage(redirectAttributes, "您不是申请人,无法修改");
+			return "redirect:"+Global.getAdminPath()+"/worksinglewage/workSingleWage/?repage";
+		}
+		if (user!=null && StringUtils.isNotBlank(user.getId()) && StringUtils.isNotBlank(sta) && "3".equals(sta)){
+			processInstanceId = workSingleWageService.get(workSingleWage.getId()).getProcessInstanceId();
+		}
+		workSingleWage.setStatus("2");
+		try {
+			Map<String, Object> variables = Maps.newHashMap();
+			workSingleWage.setCompanyId(UserUtils.getSelectCompany().getId());
+			String str = workSingleWageService.save(workSingleWage, variables,processInstanceId);
+			if (StringUtils.isNotBlank(str)){
+				addMessage(redirectAttributes, "单笔工资项提交:"+str);
+			}else {
+				addMessage(redirectAttributes, "单笔工资项已经提交");
+			}
+
+		} catch (Exception e) {
+			logger.info("Exception e:"+e);
+			addMessage(redirectAttributes, "单笔工资项提交失败!");
+		}
+		return "redirect:"+Global.getAdminPath()+"/worksinglewage/workSingleWage/?repage";
+	}
+	/**
+	 * 保存单笔工资项
+	 */
+	@RequiresPermissions(value={"worksinglewage:workSingleWage:add","worksinglewage:workSingleWage:edit"},logical=Logical.OR)
+	@RequestMapping(value = "store")
+	public String store(WorkSingleWage workSingleWage, Model model, RedirectAttributes redirectAttributes) throws Exception{
+		if (!beanValidator(model, workSingleWage)){
+			return form(workSingleWage, model);
+		}
+		workSingleWage.setStatus("1");
+		if (StringUtils.isNotBlank(workSingleWage.getProcessInstanceId()) && workSingleWage.getProcessInstanceId().equals("NULL")){
+			workSingleWage.setProcessInstanceId("");
+		}
+		workSingleWageService.save(workSingleWage);//保存
+		addMessage(redirectAttributes, "保存单笔工资项成功");
+		return "redirect:"+Global.getAdminPath()+"/worksinglewage/workSingleWage/?repage";
+	}
+
+	/**
+	 * 工单执行(完成任务)
+	 * @param model
+	 * @return
+	 */
+	@RequestMapping(value = "saveAudit")
+	public String saveAudit(WorkSingleWage workSingleWage, Model model,
+							RedirectAttributes redirectAttributes) {
+		try {
+			// 对不同环节的业务逻辑进行操作
+			String taskDefKey = workSingleWage.getAct().getTaskDefKey();
+			List<User> users = null;
+			if ("bmzr".equals(taskDefKey)){
+				users = UserUtils.getByProssType(workSingleWage.getProcessInstanceId(),1);
+			}else if ("modifyApply".equals(taskDefKey)){
+				users = UserUtils.getByProssType(workSingleWage.getProcessInstanceId(),1);
+			}
+			String flag = workSingleWage.getAct().getFlag();
+			if ("yes".equals(flag) &&(users==null || users.size()==0)){
+				addMessage(redirectAttributes, "审批失败,审批人为空,请联系管理员!");
+			}else {
+				String str = workSingleWageService.auditSave(workSingleWage,users);
+				addMessage(redirectAttributes, str);
+			}
+		}catch (Exception e){
+			logger.info("Exception e:"+e);
+			addMessage(redirectAttributes, "审批失败");
+		}
+		if (StringUtils.isNotBlank(workSingleWage.getHome()) && "home".equals(workSingleWage.getHome())) {
+			return "redirect:" + Global.getAdminPath() + "/home/?repage";
+		} else {
+			return "redirect:"+Global.getAdminPath()+"/worksinglewage/workSingleWage/?repage";
+		}
+	}
+
+	/**
+	 * 删除单笔工资项
+	 */
+	@RequiresPermissions("worksinglewage:workSingleWage:del")
+	@RequestMapping(value = "delete")
+	public String delete(WorkSingleWage workSingleWage, RedirectAttributes redirectAttributes) {
+		workSingleWageService.delete(workSingleWage);
+		addMessage(redirectAttributes, "删除单笔工资项成功");
+		return "redirect:"+Global.getAdminPath()+"/worksinglewage/workSingleWage/?repage";
+	}
+	
+	/**
+	 * 批量删除单笔工资项
+	 */
+	@RequiresPermissions("worksinglewage:workSingleWage:del")
+	@RequestMapping(value = "deleteAll")
+	public String deleteAll(String ids, RedirectAttributes redirectAttributes) {
+		String idArray[] =ids.split(",");
+		for(String id : idArray){
+			workSingleWageService.delete(workSingleWageService.get(id));
+		}
+		addMessage(redirectAttributes, "删除单笔工资项成功");
+		return "redirect:"+Global.getAdminPath()+"/worksinglewage/workSingleWage/?repage";
+	}
+
+
+	/**
+	 * 合同作废:强制撤回
+	 */
+	@RequestMapping("cancelInvalidate")
+	public String cancelInvalidate(WorkSingleWage workSingleWage,RedirectAttributes redirectAttributes){
+		try {
+			WorkSingleWage singleWage = workSingleWageService.get(workSingleWage.getId());
+			if(singleWage.getStatus().equals("5")){
+				addMessage(redirectAttributes, "单笔工资项已审批通过,无法撤回");
+			}else{
+				workSingleWageService.cancelInvalidate(singleWage);
+				addMessage(redirectAttributes, "单笔工资项撤回成功");
+			}
+		}catch (Exception e){
+			logger.error("Exception e"+e);
+			addMessage(redirectAttributes, "单笔工资项撤回失败");
+		}
+		return "redirect:"+Global.getAdminPath()+"/worksinglewage/workSingleWage/?repage";
+	}
+	
+	/**
+	 * 导出excel文件
+	 */
+	@RequiresPermissions("worksinglewage:workSingleWage:export")
+    @RequestMapping(value = "export", method=RequestMethod.POST)
+    public String exportFile(WorkSingleWage workSingleWage, HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) {
+		try {
+            String fileName = "单笔工资项"+DateUtils.getDate("yyyyMMddHHmmss")+".xlsx";
+            Page<WorkSingleWage> page = workSingleWageService.findPage(new Page<WorkSingleWage>(request, response, -1), workSingleWage);
+    		new ExportExcel("单笔工资项", WorkSingleWage.class).setDataList(page.getList()).write(response, fileName).dispose();
+    		return null;
+		} catch (Exception e) {
+			addMessage(redirectAttributes, "导出单笔工资项记录失败!失败信息:"+e.getMessage());
+		}
+		return "redirect:"+Global.getAdminPath()+"/worksinglewage/workSingleWage/?repage";
+    }
+
+	/**
+	 * 导入Excel数据
+
+	 */
+	@RequiresPermissions("worksinglewage:workSingleWage:import")
+    @RequestMapping(value = "import", method=RequestMethod.POST)
+    public String importFile(MultipartFile file, RedirectAttributes redirectAttributes) {
+		try {
+			int successNum = 0;
+			int failureNum = 0;
+			StringBuilder failureMsg = new StringBuilder();
+			ImportExcel ei = new ImportExcel(file, 1, 0);
+			List<WorkSingleWage> list = ei.getDataList(WorkSingleWage.class);
+			for (WorkSingleWage workSingleWage : list){
+				try{
+					workSingleWageService.save(workSingleWage);
+					successNum++;
+				}catch(ConstraintViolationException ex){
+					failureNum++;
+				}catch (Exception ex) {
+					failureNum++;
+				}
+			}
+			if (failureNum>0){
+				failureMsg.insert(0, ",失败 "+failureNum+" 条单笔工资项记录。");
+			}
+			addMessage(redirectAttributes, "已成功导入 "+successNum+" 条单笔工资项记录"+failureMsg);
+		} catch (Exception e) {
+			addMessage(redirectAttributes, "导入单笔工资项失败!失败信息:"+e.getMessage());
+		}
+		return "redirect:"+Global.getAdminPath()+"/worksinglewage/workSingleWage/?repage";
+    }
+	
+	/**
+	 * 下载导入单笔工资项数据模板
+	 */
+	@RequiresPermissions("worksinglewage:workSingleWage:import")
+    @RequestMapping(value = "import/template")
+    public String importFileTemplate(HttpServletResponse response, RedirectAttributes redirectAttributes) {
+		try {
+            String fileName = "单笔工资项数据导入模板.xlsx";
+    		List<WorkSingleWage> list = Lists.newArrayList(); 
+    		new ExportExcel("单笔工资项数据", WorkSingleWage.class, 1).setDataList(list).write(response, fileName).dispose();
+    		return null;
+		} catch (Exception e) {
+			addMessage(redirectAttributes, "导入模板下载失败!失败信息:"+e.getMessage());
+		}
+		return "redirect:"+Global.getAdminPath()+"/worksinglewage/workSingleWage/?repage";
+    }
+
+	/**
+	 * 选择报销项目
+	 */
+	@RequestMapping(value = "selectWage")
+	public String selectWage(WorkSingleWage workSingleWage, String url, String fieldLabels, String fieldKeys, String searchLabel, String searchKey, HttpServletRequest request, HttpServletResponse response, Model model) {
+		WorkSalaryItem workSalaryItem = workSingleWage.getWorkSalaryItem();
+		if (workSalaryItem == null){
+			workSalaryItem = new WorkSalaryItem();
+		}
+		workSalaryItem.setCompanyId(UserUtils.getSelectCompany().getId());
+		workSalaryItem.setState("2");
+		Page<WorkSalaryItem> page = workSalaryItemService.findPage(new Page<WorkSalaryItem>(request, response), workSalaryItem);
+		try {
+			searchLabel = URLDecoder.decode(searchLabel, "UTF-8");
+			fieldLabels = URLDecoder.decode(fieldLabels, "UTF-8");
+			searchKey = URLDecoder.decode(searchKey, "UTF-8");
+			fieldKeys = URLDecoder.decode(fieldKeys, "UTF-8");
+		} catch (UnsupportedEncodingException e) {
+			e.printStackTrace();
+		}
+		model.addAttribute("labelNames", fieldLabels.split("\\|"));
+		model.addAttribute("labelValues", fieldKeys.split("\\|"));
+		model.addAttribute("fieldLabels", fieldLabels);
+		model.addAttribute("fieldKeys", fieldKeys);
+		model.addAttribute("url", url);
+		model.addAttribute("searchLabel", searchLabel);
+		model.addAttribute("searchKey", searchKey);
+		model.addAttribute("obj", workSingleWage);
+		model.addAttribute("allowInput", true);
+		model.addAttribute("page", page);
+		return "modules/sys/gridselectcallwage";
+		//return "modules/sys/gridselect";
+	}
+
+	/**
+	 * 读取单个实体流程
+	 * @return
+	 */
+	@RequestMapping(value = "getProcessOne")
+	public String getProcessOne(WorkSingleWage workSingleWage,Model model) {
+		model.addAttribute("processInstanceId", workSingleWage.getProcessInstanceId());
+		return "modules/workreimbursement/workReimbursementTrack";
+	}
+
+}

+ 19 - 0
src/main/java/com/jeeplus/modules/workstaff/dao/WorkStaffAchievementDao.java

@@ -0,0 +1,19 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workstaff.dao;
+
+import com.jeeplus.common.persistence.CrudDao;
+import com.jeeplus.common.persistence.annotation.MyBatisDao;
+import com.jeeplus.modules.workstaff.entity.WorkStaffAchievement;
+
+/**
+ * 工作业绩DAO接口
+ * @author ssrh
+ * @version 2018-07-27
+ */
+@MyBatisDao
+public interface WorkStaffAchievementDao extends CrudDao<WorkStaffAchievement> {
+    int updateFalt(String id);
+	
+}

+ 52 - 0
src/main/java/com/jeeplus/modules/workstaff/dao/WorkStaffAchivesBackDao.java

@@ -0,0 +1,52 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workstaff.dao;
+
+import com.jeeplus.common.persistence.CrudDao;
+import com.jeeplus.common.persistence.annotation.MyBatisDao;
+import com.jeeplus.modules.workstaff.entity.WorkStaffBasicInfo;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 员工基本信息DAO接口
+ * @author ssrh
+ * @version 2018-07-26
+ */
+@MyBatisDao
+public interface WorkStaffAchivesBackDao extends CrudDao<WorkStaffBasicInfo> {
+
+  public WorkStaffBasicInfo  getWorkStaffBasicInfo(String id);//根据用户获取用户入职信息
+    public Integer getByCompany(WorkStaffBasicInfo workStaffBasicInfo);//根据用户获取用户入职信息
+    public Integer getByBranchCompany(WorkStaffBasicInfo workStaffBasicInfo);//根据用户获取用户入职信息
+    public List<WorkStaffBasicInfo> getByCompanyInfo(WorkStaffBasicInfo workStaffBasicInfo);//根据用户获取用户入职信息
+    List<WorkStaffBasicInfo> findListByRoleList(WorkStaffBasicInfo select);
+    String queryMaxNoWithCompany(WorkStaffBasicInfo workStaffBasicInfo);
+
+ public List<WorkStaffBasicInfo>  findUserList(WorkStaffBasicInfo workStaffBasicInfo);
+    public List<WorkStaffBasicInfo>  findUserApplyList(WorkStaffBasicInfo workStaffBasicInfo);
+    public List<WorkStaffBasicInfo>  getAllListInfo(WorkStaffBasicInfo workStaffBasicInfo);
+    public List<WorkStaffBasicInfo>  findInfoList(WorkStaffBasicInfo workStaffBasicInfo);
+
+    List<WorkStaffBasicInfo> findListByIdCard(WorkStaffBasicInfo select);
+
+    public List<WorkStaffBasicInfo>  findTaskUserList(@Param("day") int day, @Param("branchOffice") String branchOffice);
+
+    void updatePercent(@Param("id") String id, @Param("percent") String percent);
+    public WorkStaffBasicInfo  findUserInfoExcel(WorkStaffBasicInfo workStaffBasicInfo);
+    public List<WorkStaffBasicInfo>  findTemplateUser(WorkStaffBasicInfo workStaffBasicInfo);
+    public List<WorkStaffBasicInfo>  sysWarningUser(WorkStaffBasicInfo workStaffBasicInfo);
+    public List<WorkStaffBasicInfo>  findTaskBranchList(WorkStaffBasicInfo workStaffBasicInfo);
+
+    int countByNo(WorkStaffBasicInfo workStaffBasicInfo);
+
+    //通过用户,部门获取档案信息
+    public WorkStaffBasicInfo getByUserOffice(WorkStaffBasicInfo workStaffBasicInfo);
+    public List<WorkStaffBasicInfo> getByOffice(WorkStaffBasicInfo workStaffBasicInfo);
+    //<!--当前登录人获取档案-->
+    public WorkStaffBasicInfo getBasicInfo(WorkStaffBasicInfo workStaffBasicInfo);
+
+    public WorkStaffBasicInfo getByNoName(WorkStaffBasicInfo workStaffBasicInfo);
+}

+ 58 - 0
src/main/java/com/jeeplus/modules/workstaff/dao/WorkStaffAchivesDao.java

@@ -0,0 +1,58 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workstaff.dao;
+
+import com.jeeplus.common.persistence.CrudDao;
+import com.jeeplus.common.persistence.annotation.MyBatisDao;
+import com.jeeplus.modules.workstaff.entity.WorkStaffBasicInfo;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 员工基本信息DAO接口
+ * @author ssrh
+ * @version 2018-07-26
+ */
+@MyBatisDao
+public interface WorkStaffAchivesDao extends CrudDao<WorkStaffBasicInfo> {
+
+  public WorkStaffBasicInfo  getWorkStaffBasicInfo(String id);//根据用户获取用户入职信息
+    WorkStaffBasicInfo getByUserId(String id);
+    public Integer getByCompany(WorkStaffBasicInfo workStaffBasicInfo);//根据用户获取用户入职信息
+    public Integer getByBranchCompany(WorkStaffBasicInfo workStaffBasicInfo);//根据用户获取用户入职信息
+    public List<WorkStaffBasicInfo> getByCompanyInfo(WorkStaffBasicInfo workStaffBasicInfo);//根据用户获取用户入职信息
+    List<WorkStaffBasicInfo> findListByRoleList(WorkStaffBasicInfo select);
+    String queryMaxNoWithCompany(WorkStaffBasicInfo workStaffBasicInfo);
+
+ public List<WorkStaffBasicInfo>  findUserList(WorkStaffBasicInfo workStaffBasicInfo);
+    public List<WorkStaffBasicInfo>  findUserApplyList(WorkStaffBasicInfo workStaffBasicInfo);
+    public List<WorkStaffBasicInfo>  getAllListInfo(WorkStaffBasicInfo workStaffBasicInfo);
+    public List<WorkStaffBasicInfo>  findInfoList(WorkStaffBasicInfo workStaffBasicInfo);
+    public List<WorkStaffBasicInfo>  findUserShipList(WorkStaffBasicInfo workStaffBasicInfo);
+    List<WorkStaffBasicInfo> findListByIdCard(WorkStaffBasicInfo select);
+
+    public List<WorkStaffBasicInfo>  findTaskUserList(@Param("day") int day, @Param("branchOffice") String branchOffice);
+
+    void updatePercent(@Param("id") String id, @Param("percent") String percent);
+    public WorkStaffBasicInfo  findUserInfoExcel(WorkStaffBasicInfo workStaffBasicInfo);
+    public List<WorkStaffBasicInfo>  findTemplateUser(WorkStaffBasicInfo workStaffBasicInfo);
+    public List<WorkStaffBasicInfo>  sysWarningUser(WorkStaffBasicInfo workStaffBasicInfo);
+    public List<WorkStaffBasicInfo>  findTaskBranchList(WorkStaffBasicInfo workStaffBasicInfo);
+
+    int countByNo(WorkStaffBasicInfo workStaffBasicInfo);
+
+    //通过用户,部门获取档案信息
+    public WorkStaffBasicInfo getByUserOffice(WorkStaffBasicInfo workStaffBasicInfo);
+    public List<WorkStaffBasicInfo> getByOffice(WorkStaffBasicInfo workStaffBasicInfo);
+    //<!--当前登录人获取档案-->
+    public WorkStaffBasicInfo getBasicInfo(WorkStaffBasicInfo workStaffBasicInfo);
+
+    public WorkStaffBasicInfo getByNoName(WorkStaffBasicInfo workStaffBasicInfo);
+    public WorkStaffBasicInfo getJob(String userId);
+
+    void updateStatus(@Param("id") String id, @Param("status") String status);
+
+    void updateWorkStaffAchieves(WorkStaffBasicInfo workStaffBasicInfo);
+}

+ 77 - 0
src/main/java/com/jeeplus/modules/workstaff/dao/WorkStaffBasicInfoDao.java

@@ -0,0 +1,77 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workstaff.dao;
+
+import com.jeeplus.common.persistence.CrudDao;
+import com.jeeplus.common.persistence.annotation.MyBatisDao;
+import com.jeeplus.modules.workstaff.entity.WorkStaffBasicInfo;
+import com.sun.corba.se.spi.orbutil.threadpool.Work;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 员工基本信息DAO接口
+ * @author ssrh
+ * @version 2018-07-26
+ */
+@MyBatisDao
+public interface WorkStaffBasicInfoDao extends CrudDao<WorkStaffBasicInfo> {
+    /**
+     * 根据用户id,多表查询获取用户入职信息
+     * @param userId
+     * @return
+     */
+    public WorkStaffBasicInfo  getWorkStaffBasicInfoByUserId(String userId);
+
+    public WorkStaffBasicInfo  getWorkStaffBasicInfo(String id);//根据用户获取用户入职信息
+    public Integer getByCompany(WorkStaffBasicInfo workStaffBasicInfo);//根据用户获取用户入职信息
+    public WorkStaffBasicInfo getByCompanyInfo(WorkStaffBasicInfo workStaffBasicInfo);//根据用户获取用户入职信息
+
+    public  String queryMaxNoWithCompany(WorkStaffBasicInfo workStaffBasicInfo);
+
+    public List<WorkStaffBasicInfo>  findUserList(WorkStaffBasicInfo workStaffBasicInfo);
+
+    List<WorkStaffBasicInfo> findListByIdCard(WorkStaffBasicInfo select);
+
+    List<WorkStaffBasicInfo> findListByRoleList(WorkStaffBasicInfo select);
+
+    List<WorkStaffBasicInfo> findAddressBook(WorkStaffBasicInfo select);   //通讯录
+
+    List<WorkStaffBasicInfo> findListByAchiveId(WorkStaffBasicInfo workStaffBasicInfo);
+
+    List<WorkStaffBasicInfo> findListByUserId(WorkStaffBasicInfo workStaffBasicInfo);
+
+    void updateStatus(@Param("id") String id, @Param("status") String status);
+
+    int deleteByLogic(WorkStaffBasicInfo workStaffBasicInfo);
+
+    WorkStaffBasicInfo getNo(String no);
+
+    List<WorkStaffBasicInfo> findByMob(WorkStaffBasicInfo workStaffBasicInfo);
+
+    WorkStaffBasicInfo findByCard(String cardNo);
+
+    List<WorkStaffBasicInfo> findByName(String name);
+
+    int updateWorkStaffBasicInfo(WorkStaffBasicInfo workStaffBasicInfo);
+
+    WorkStaffBasicInfo getByAchieveId(String achieveId);
+
+    /**
+     * 更新员工职级
+     * @param userId
+     * @param jobGradeId
+     * @return
+     */
+    int updateJobGradeByUserId(@Param("userId") String userId,@Param("jobGradeId") String jobGradeId);
+
+    /**
+     * 更新员工所属部门
+     * @param userId
+     * @param officeId
+     * @return
+     */
+    int updateOfficeByUserId(@Param("userId") String userId,@Param("officeId") String officeId);
+}

+ 19 - 0
src/main/java/com/jeeplus/modules/workstaff/dao/WorkStaffCertificateDao.java

@@ -0,0 +1,19 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workstaff.dao;
+
+import com.jeeplus.common.persistence.CrudDao;
+import com.jeeplus.common.persistence.annotation.MyBatisDao;
+import com.jeeplus.modules.workstaff.entity.WorkStaffCertificate;
+
+/**
+ * 执业资格证书DAO接口
+ * @author ssrh
+ * @version 2018-07-27
+ */
+@MyBatisDao
+public interface WorkStaffCertificateDao extends CrudDao<WorkStaffCertificate> {
+    int updateFalt(String id);
+	
+}

+ 19 - 0
src/main/java/com/jeeplus/modules/workstaff/dao/WorkStaffEducationDao.java

@@ -0,0 +1,19 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workstaff.dao;
+
+import com.jeeplus.common.persistence.CrudDao;
+import com.jeeplus.common.persistence.annotation.MyBatisDao;
+import com.jeeplus.modules.workstaff.entity.WorkStaffEducation;
+
+/**
+ * 教育经历DAO接口
+ * @author ssrh
+ * @version 2018-07-27
+ */
+@MyBatisDao
+public interface WorkStaffEducationDao extends CrudDao<WorkStaffEducation> {
+ int updateFalt(String id);
+	
+}

+ 19 - 0
src/main/java/com/jeeplus/modules/workstaff/dao/WorkStaffExperienceDao.java

@@ -0,0 +1,19 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workstaff.dao;
+
+import com.jeeplus.common.persistence.CrudDao;
+import com.jeeplus.common.persistence.annotation.MyBatisDao;
+import com.jeeplus.modules.workstaff.entity.WorkStaffExperience;
+
+/**
+ * 工作经历DAO接口
+ * @author ssrh
+ * @version 2018-07-27
+ */
+@MyBatisDao
+public interface WorkStaffExperienceDao extends CrudDao<WorkStaffExperience> {
+    int updateFalt(String id);
+	
+}

+ 19 - 0
src/main/java/com/jeeplus/modules/workstaff/dao/WorkStaffFamilyDao.java

@@ -0,0 +1,19 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workstaff.dao;
+
+import com.jeeplus.common.persistence.CrudDao;
+import com.jeeplus.common.persistence.annotation.MyBatisDao;
+import com.jeeplus.modules.workstaff.entity.WorkStaffFamily;
+
+/**
+ * 家庭情况DAO接口
+ * @author ssrh
+ * @version 2018-07-27
+ */
+@MyBatisDao
+public interface WorkStaffFamilyDao extends CrudDao<WorkStaffFamily> {
+    int updateFalt(String id);
+	
+}

+ 19 - 0
src/main/java/com/jeeplus/modules/workstaff/dao/WorkStaffLanguagesDao.java

@@ -0,0 +1,19 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workstaff.dao;
+
+import com.jeeplus.common.persistence.CrudDao;
+import com.jeeplus.common.persistence.annotation.MyBatisDao;
+import com.jeeplus.modules.workstaff.entity.WorkStaffLanguages;
+
+/**
+ * 外语信息DAO接口
+ * @author ssrh
+ * @version 2018-07-27
+ */
+@MyBatisDao
+public interface WorkStaffLanguagesDao extends CrudDao<WorkStaffLanguages> {
+    int updateFalt(String id);
+	
+}

+ 19 - 0
src/main/java/com/jeeplus/modules/workstaff/dao/WorkStaffRecordDao.java

@@ -0,0 +1,19 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workstaff.dao;
+
+import com.jeeplus.common.persistence.CrudDao;
+import com.jeeplus.common.persistence.annotation.MyBatisDao;
+import com.jeeplus.modules.workstaff.entity.WorkStaffRecord;
+
+/**
+ * 电子档案DAO接口
+ * @author ssrh
+ * @version 2018-07-27
+ */
+@MyBatisDao
+public interface WorkStaffRecordDao extends CrudDao<WorkStaffRecord> {
+    int updateFalt(String id);
+	
+}

+ 19 - 0
src/main/java/com/jeeplus/modules/workstaff/dao/WorkStaffRewardsDao.java

@@ -0,0 +1,19 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workstaff.dao;
+
+import com.jeeplus.common.persistence.CrudDao;
+import com.jeeplus.common.persistence.annotation.MyBatisDao;
+import com.jeeplus.modules.workstaff.entity.WorkStaffRewards;
+
+/**
+ * 奖惩情况DAO接口
+ * @author ssrh
+ * @version 2018-07-27
+ */
+@MyBatisDao
+public interface WorkStaffRewardsDao extends CrudDao<WorkStaffRewards> {
+    int updateFalt(String id);
+	
+}

+ 19 - 0
src/main/java/com/jeeplus/modules/workstaff/dao/WorkStaffSocialPositionDao.java

@@ -0,0 +1,19 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workstaff.dao;
+
+import com.jeeplus.common.persistence.CrudDao;
+import com.jeeplus.common.persistence.annotation.MyBatisDao;
+import com.jeeplus.modules.workstaff.entity.WorkStaffSocialPosition;
+
+/**
+ * 社会及行业职务DAO接口
+ * @author ssrh
+ * @version 2018-07-27
+ */
+@MyBatisDao
+public interface WorkStaffSocialPositionDao extends CrudDao<WorkStaffSocialPosition> {
+    int updateFalt(String id);
+	
+}

+ 19 - 0
src/main/java/com/jeeplus/modules/workstaff/dao/WorkStaffTitleDao.java

@@ -0,0 +1,19 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workstaff.dao;
+
+import com.jeeplus.common.persistence.CrudDao;
+import com.jeeplus.common.persistence.annotation.MyBatisDao;
+import com.jeeplus.modules.workstaff.entity.WorkStaffTitle;
+
+/**
+ * 职称DAO接口
+ * @author ssrh
+ * @version 2018-07-27
+ */
+@MyBatisDao
+public interface WorkStaffTitleDao extends CrudDao<WorkStaffTitle> {
+    int updateFalt(String id);
+	
+}

+ 19 - 0
src/main/java/com/jeeplus/modules/workstaff/dao/WorkStaffTrainingDao.java

@@ -0,0 +1,19 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workstaff.dao;
+
+import com.jeeplus.common.persistence.CrudDao;
+import com.jeeplus.common.persistence.annotation.MyBatisDao;
+import com.jeeplus.modules.workstaff.entity.WorkStaffTraining;
+
+/**
+ * 培训经历DAO接口
+ * @author ssrh
+ * @version 2018-07-27
+ */
+@MyBatisDao
+public interface WorkStaffTrainingDao extends CrudDao<WorkStaffTraining> {
+    int updateFalt(String id);
+	
+}

+ 97 - 0
src/main/java/com/jeeplus/modules/workstaff/entity/WorkStaffAchievement.java

@@ -0,0 +1,97 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workstaff.entity;
+
+
+import com.jeeplus.common.persistence.DataEntity;
+import com.jeeplus.common.utils.excel.annotation.ExcelField;
+
+/**
+ * 工作业绩Entity
+ * @author ssrh
+ * @version 2018-07-27
+ */
+public class WorkStaffAchievement extends DataEntity<WorkStaffAchievement> {
+	
+	private static final long serialVersionUID = 1L;
+	private String staff;		// 员工ID
+	private String projName;		// 项目名称
+	private String projClient;		// 主委托方
+	private String category;		// 工程分类
+	private String unitNumber;		// 规模类型/单位/数量
+	private String duty;		// 担任职务
+	private String content;		// 参与内容
+	
+	public WorkStaffAchievement() {
+		super();
+	}
+
+	public WorkStaffAchievement(String id){
+		super(id);
+	}
+
+	@ExcelField(title="员工ID", align=2, sort=7)
+	public String getStaff() {
+		return staff;
+	}
+
+	public void setStaff(String staff) {
+		this.staff = staff;
+	}
+	
+	@ExcelField(title="项目名称", align=2, sort=8)
+	public String getProjName() {
+		return projName;
+	}
+
+	public void setProjName(String projName) {
+		this.projName = projName;
+	}
+	
+	@ExcelField(title="主委托方", align=2, sort=9)
+	public String getProjClient() {
+		return projClient;
+	}
+
+	public void setProjClient(String projClient) {
+		this.projClient = projClient;
+	}
+	
+	@ExcelField(title="工程分类", align=2, sort=10)
+	public String getCategory() {
+		return category;
+	}
+
+	public void setCategory(String category) {
+		this.category = category;
+	}
+	
+	@ExcelField(title="规模类型/单位/数量", align=2, sort=11)
+	public String getUnitNumber() {
+		return unitNumber;
+	}
+
+	public void setUnitNumber(String unitNumber) {
+		this.unitNumber = unitNumber;
+	}
+	
+	@ExcelField(title="担任职务", dictType="", align=2, sort=12)
+	public String getDuty() {
+		return duty;
+	}
+
+	public void setDuty(String duty) {
+		this.duty = duty;
+	}
+	
+	@ExcelField(title="参与内容", align=2, sort=13)
+	public String getContent() {
+		return content;
+	}
+
+	public void setContent(String content) {
+		this.content = content;
+	}
+	
+}

+ 719 - 0
src/main/java/com/jeeplus/modules/workstaff/entity/WorkStaffBasicInfo.java

@@ -0,0 +1,719 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workstaff.entity;
+
+import com.jeeplus.modules.sys.entity.Office;
+import java.util.Date;
+import java.util.List;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.jeeplus.modules.sys.entity.Area;
+
+import com.jeeplus.common.persistence.DataEntity;
+import com.jeeplus.common.utils.excel.annotation.ExcelField;
+import com.jeeplus.modules.workjobgrade.entity.WorkJobGrade;
+import com.jeeplus.modules.workrelationship.entity.WorkRelationship;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.validation.constraints.Size;
+
+/**
+ * 员工基本信息Entity
+ * @author ssrh
+ * @version 2018-07-26
+ */
+public class WorkStaffBasicInfo extends DataEntity<WorkStaffBasicInfo> {
+	
+	private static final long serialVersionUID = 1L;
+	private String userId;
+	private String sqlStr;
+	private Date tryEndTime;
+	private Office office;		// 部门ID
+	private Office company;		// 公司ID
+	private Office branchOffice;		// 公司ID
+    private String no;		// 工    号
+	private String name;		// 姓    名
+	private String gender;		// 性    别
+	private String nation;		// 民    族
+	private String idCard;		// 身份证号码
+	private Integer age;		// 年    龄
+	private Date birthday;		// 出生日期
+	private String calendar;		// 公历/农历
+	private String email;		// 电子邮箱
+	private String mobile;		// 移动电话
+	private String phone;		// 座机
+	private String marriage;		// 婚姻状况
+	private String politics;		// 政治面貌
+	private String exSoldier;		// 是否退伍军人
+	private String address;		// 常住地址
+	private Area nativePlace;		// 籍    贯
+	private String household;		// 户口所在地
+	private String duty;		// 职务
+	private WorkJobGrade jobGrade;		// 职    级
+	private Double salary;		// 基本工资
+	private String status;		// 员工状态
+	private Date entryDate;		// 入职日期
+	private Date workDate;		// 参加工作日期
+	private String bankName;		// 开户银行
+	private String bankCard;		// 银行卡号
+	private Date industryDate;		// 从事本行业日期
+	private String ts;		// 是否TS人员
+	private String picture;		// 照片
+	private Date beginEntryDate;		// 开始 入职日期
+	private Date endEntryDate;		// 结束 入职日期
+    private Date dimissionDate;  //离职日期
+    private Date workEndDate;  //考勤截止日期
+    private MultipartFile pictureFile;
+    private List<WorkStaffLanguages> languageList; //外语语种
+    private List<WorkStaffExperience> experienceList; //工作经历
+    private List<WorkStaffCertificate> certificateList; //执业资格证书
+    private List<WorkStaffAchievement> achievementList;//工作业绩
+    private List<WorkStaffFamily> familyList;//家庭情况
+    private List<WorkStaffRewards> rewardsList;//奖惩情况
+    private List<WorkStaffRecord> recordList;//电子档案
+    private List<WorkStaffSocialPosition> socialPositionList;//社会及行业职务
+    private List<WorkStaffTitle> titleList;//职称
+    private List<WorkStaffTraining> trainingList;//培训经历
+    private List<WorkStaffEducation> educationList;//教育经历
+    private String achiveId;
+    private String percent;
+    private Date beginBirthdayDate;
+    private Date endBirthdayDate;
+    private Date beginWorkDate;
+    private Date endWorkDate;
+    private Integer minAge;
+    private Integer maxAge;
+    private Double minSalary;		// 基本工资
+    private Double maxSalary;		// 基本工资
+    private String minPercent;		// 基本工资
+    private String maxPercent;		// 基本工资
+    private String home;		// 基本工资
+	private String roleId;
+	private String roleName;
+
+    private String nowDate;
+    private String userName;
+    private String errInfo;
+
+	//劳动关系临时属性
+	private String relationshipStatus;
+    public List<WorkStaffEducation> getEducationList() {
+        return educationList;
+    }
+
+    public void setEducationList(List<WorkStaffEducation> educationList) {
+        this.educationList = educationList;
+    }
+
+    public String getSqlStr() {
+		return sqlStr;
+	}
+
+    private List<WorkRelationship> labourList;//劳务关系
+    private String notifyFlag;
+
+    public List<WorkRelationship> getLabourList() {
+        return labourList;
+    }
+
+    public void setLabourList(List<WorkRelationship> labourList) {
+        this.labourList = labourList;
+    }
+
+	public void setSqlStr(String sqlStr) {
+		this.sqlStr = sqlStr;
+	}
+    public List<WorkStaffLanguages> getLanguageList() {
+        return languageList;
+    }
+
+    public void setLanguageList(List<WorkStaffLanguages> languageList) {
+        this.languageList = languageList;
+    }
+
+    public List<WorkStaffExperience> getExperienceList() {
+        return experienceList;
+    }
+
+    public void setExperienceList(List<WorkStaffExperience> experienceList) {
+        this.experienceList = experienceList;
+    }
+
+    public List<WorkStaffCertificate> getCertificateList() {
+        return certificateList;
+    }
+
+    public void setCertificateList(List<WorkStaffCertificate> certificateList) {
+        this.certificateList = certificateList;
+    }
+
+    public List<WorkStaffAchievement> getAchievementList() {
+        return achievementList;
+    }
+
+    public void setAchievementList(List<WorkStaffAchievement> achievementList) {
+        this.achievementList = achievementList;
+    }
+
+    public List<WorkStaffFamily> getFamilyList() {
+        return familyList;
+    }
+
+    public void setFamilyList(List<WorkStaffFamily> familyList) {
+        this.familyList = familyList;
+    }
+
+    public List<WorkStaffRewards> getRewardsList() {
+        return rewardsList;
+    }
+
+    public void setRewardsList(List<WorkStaffRewards> rewardsList) {
+        this.rewardsList = rewardsList;
+    }
+
+    public List<WorkStaffRecord> getRecordList() {
+        return recordList;
+    }
+
+    public void setRecordList(List<WorkStaffRecord> recordList) {
+        this.recordList = recordList;
+    }
+
+    public List<WorkStaffSocialPosition> getSocialPositionList() {
+        return socialPositionList;
+    }
+
+    public void setSocialPositionList(List<WorkStaffSocialPosition> socialPositionList) {
+        this.socialPositionList = socialPositionList;
+    }
+
+    public List<WorkStaffTitle> getTitleList() {
+        return titleList;
+    }
+
+    public void setTitleList(List<WorkStaffTitle> titleList) {
+        this.titleList = titleList;
+    }
+
+    public List<WorkStaffTraining> getTrainingList() {
+        return trainingList;
+    }
+
+    public void setTrainingList(List<WorkStaffTraining> trainingList) {
+        this.trainingList = trainingList;
+    }
+
+    public MultipartFile getPictureFile() {
+        return pictureFile;
+    }
+
+    public void setPictureFile(MultipartFile pictureFile) {
+        this.pictureFile = pictureFile;
+    }
+
+    public WorkStaffBasicInfo() {
+		super();
+	}
+
+	public WorkStaffBasicInfo(String id){
+		super(id);
+	}
+
+	@ExcelField(title="部门", fieldType=Office.class, value="office.name", align=2, sort=1)
+	public Office getOffice() {
+		return office;
+	}
+
+	public void setOffice(Office office) {
+		this.office = office;
+	}
+	
+	public Office getCompany() {
+		return company;
+	}
+
+	public void setCompany(Office company) {
+		this.company = company;
+	}
+	
+	@ExcelField(title="工    号", align=2, sort=2)
+	public String getNo() {
+		return no;
+	}
+
+	public void setNo(String no) {
+		this.no = no;
+	}
+	
+	@ExcelField(title="姓    名", align=2, sort=3)
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+	
+	@ExcelField(title="性    别", dictType="sex", align=2, sort=4)
+	public String getGender() {
+		return gender;
+	}
+
+	public void setGender(String gender) {
+		this.gender = gender;
+	}
+	
+	@ExcelField(title="民    族", dictType="nation_type", align=2, sort=5)
+	public String getNation() {
+		return nation;
+	}
+
+	public void setNation(String nation) {
+		this.nation = nation;
+	}
+	
+	@ExcelField(title="身份证号码", align=2, sort=6)
+	public String getIdCard() {
+		return idCard;
+	}
+
+	public void setIdCard(String idCard) {
+		this.idCard = idCard;
+	}
+
+    @ExcelField(title="年    龄", align=2, sort=7)
+	public String getAgeStr(){
+        return String.valueOf(age);
+    }
+
+    public void setAgeStr(String age){
+        this.age = Integer.valueOf(age);
+    }
+	public Integer getAge() {
+		return age;
+	}
+
+	public void setAge(Integer age) {
+		this.age = age;
+	}
+	
+	@JsonFormat(pattern = "yyyy-MM-dd")
+	@ExcelField(title="出生日期", align=2, sort=8)
+	public Date getBirthday() {
+		return birthday;
+	}
+
+	public void setBirthday(Date birthday) {
+		this.birthday = birthday;
+	}
+	
+	@ExcelField(title="公历/农历", dictType="calendar_type", align=2, sort=9)
+	public String getCalendar() {
+		return calendar;
+	}
+
+	public void setCalendar(String calendar) {
+		this.calendar = calendar;
+	}
+	
+	@ExcelField(title="电子邮箱", align=2, sort=10)
+	public String getEmail() {
+		return email;
+	}
+
+	public void setEmail(String email) {
+		this.email = email;
+	}
+	
+	@ExcelField(title="移动电话", align=2, sort=11)
+	public String getMobile() {
+		return mobile;
+	}
+
+	public void setMobile(String mobile) {
+		this.mobile = mobile;
+	}
+
+	@ExcelField(title="座机", align=2, sort=11)
+	public String getPhone() {
+		return phone;
+	}
+
+	public void setPhone(String phone) {
+		this.phone = phone;
+	}
+
+	@ExcelField(title="婚姻状况", align=2, sort=12,valiName = "marriage_status")
+	public String getMarriage() {
+		return marriage;
+	}
+
+	public void setMarriage(String marriage) {
+		this.marriage = marriage;
+	}
+	
+	@ExcelField(title="政治面貌", align=2, sort=13, valiName = "politics_type")
+	public String getPolitics() {
+		return politics;
+	}
+
+	public void setPolitics(String politics) {
+		this.politics = politics;
+	}
+	
+	@ExcelField(title="是否退伍军人", dictType="yes_no", align=2, sort=14)
+	public String getExSoldier() {
+		return exSoldier;
+	}
+
+	public void setExSoldier(String exSoldier) {
+		this.exSoldier = exSoldier;
+	}
+	
+	@ExcelField(title="常住地址", align=2, sort=15)
+	public String getAddress() {
+		return address;
+	}
+
+	public void setAddress(String address) {
+		this.address = address;
+	}
+	
+	@ExcelField(title="籍    贯", fieldType=Area.class, value="", align=2, sort=16)
+	public Area getNativePlace() {
+		return nativePlace;
+	}
+
+	public void setNativePlace(Area nativePlace) {
+		this.nativePlace = nativePlace;
+	}
+	
+	@ExcelField(title="户口所在地", align=2, sort=17)
+	public String getHousehold() {
+		return household;
+	}
+
+	public void setHousehold(String household) {
+		this.household = household;
+	}
+	
+	@ExcelField(title="职务", align=2, sort=18,valiName = "staff_duty")
+	public String getDuty() {
+		return duty;
+	}
+
+	public void setDuty(String duty) {
+		this.duty = duty;
+	}
+	
+	@ExcelField(title="职    级", align=2, value="jobGrade.name", sort=19, valiName = "WorkJobGrade")
+	public WorkJobGrade getJobGrade() {
+		return jobGrade;
+	}
+
+	public void setJobGrade(WorkJobGrade jobGrade) {
+		this.jobGrade = jobGrade;
+	}
+	
+	@ExcelField(title="员工状态", align=2, sort=20, valiName = "staff_status")
+	public String getStatus() {
+		return status;
+	}
+
+	public void setStatus(String status) {
+		this.status = status;
+	}
+	
+	@JsonFormat(pattern = "yyyy-MM-dd")
+	@ExcelField(title="入职日期", align=2, sort=21)
+	public Date getEntryDate() {
+		return entryDate;
+	}
+
+	public void setEntryDate(Date entryDate) {
+		this.entryDate = entryDate;
+	}
+	
+	@JsonFormat(pattern = "yyyy-MM-dd")
+	@ExcelField(title="参加工作日期", align=2, sort=22)
+	public Date getWorkDate() {
+		return workDate;
+	}
+
+	public void setWorkDate(Date workDate) {
+		this.workDate = workDate;
+	}
+	
+	@ExcelField(title="开户银行", align=2, sort=23, valiName = "bank_type")
+	public String getBankName() {
+		return bankName;
+	}
+
+	public void setBankName(String bankName) {
+		this.bankName = bankName;
+	}
+	
+	@ExcelField(title="银行卡号", align=2, sort=24)
+	public String getBankCard() {
+		return bankCard;
+	}
+
+	public void setBankCard(String bankCard) {
+		this.bankCard = bankCard;
+	}
+	
+	@JsonFormat(pattern = "yyyy-MM-dd")
+	@ExcelField(title="从事本行业日期", align=2, sort=25)
+	public Date getIndustryDate() {
+		return industryDate;
+	}
+
+	public void setIndustryDate(Date industryDate) {
+		this.industryDate = industryDate;
+	}
+	
+	@ExcelField(title="是否TS人员", dictType="yes_no", align=2, sort=26)
+	public String getTs() {
+		return ts;
+	}
+
+	public void setTs(String ts) {
+		this.ts = ts;
+	}
+	
+	public String getPicture() {
+		return picture;
+	}
+
+	public void setPicture(String picture) {
+		this.picture = picture;
+	}
+	
+	public Date getBeginEntryDate() {
+		return beginEntryDate;
+	}
+
+	public void setBeginEntryDate(Date beginEntryDate) {
+		this.beginEntryDate = beginEntryDate;
+	}
+	
+	public Date getEndEntryDate() {
+		return endEntryDate;
+	}
+
+	public void setEndEntryDate(Date endEntryDate) {
+		this.endEntryDate = endEntryDate;
+	}
+
+    public Date getDimissionDate() {
+        return dimissionDate;
+    }
+
+    public void setDimissionDate(Date dimissionDate) {
+        this.dimissionDate = dimissionDate;
+    }
+	public String getUserId() {
+		return userId;
+	}
+
+	public void setUserId(String userId) {
+		this.userId = userId;
+	}
+
+    public Office getBranchOffice() {
+        return branchOffice;
+    }
+
+    public void setBranchOffice(Office branchOffice) {
+        this.branchOffice = branchOffice;
+    }
+
+    public Double getSalary() {
+        return salary;
+    }
+
+    public void setSalary(Double salary) {
+        this.salary = salary;
+    }
+
+    public Date getWorkEndDate() {
+        return workEndDate;
+    }
+
+    public void setWorkEndDate(Date workEndDate) {
+        this.workEndDate = workEndDate;
+    }
+
+    public String getNotifyFlag() {
+        return notifyFlag;
+    }
+
+    public void setNotifyFlag(String notifyFlag) {
+        this.notifyFlag = notifyFlag;
+    }
+
+    public String getAchiveId() {
+        return achiveId;
+    }
+
+    public void setAchiveId(String achiveId) {
+        this.achiveId = achiveId;
+    }
+
+	public String getRelationshipStatus() {
+		return relationshipStatus;
+	}
+
+	public void setRelationshipStatus(String relationshipStatus) {
+		this.relationshipStatus = relationshipStatus;
+	}
+
+
+	public Date getTryEndTime() {
+		return tryEndTime;
+	}
+
+	public void setTryEndTime(Date tryEndTime) {
+		this.tryEndTime = tryEndTime;
+	}
+
+    public String getPercent() {
+        return percent;
+    }
+
+    public void setPercent(String percent) {
+        this.percent = percent;
+    }
+
+    public Date getBeginBirthdayDate() {
+        return beginBirthdayDate;
+    }
+
+    public void setBeginBirthdayDate(Date beginBirthdayDate) {
+        this.beginBirthdayDate = beginBirthdayDate;
+    }
+
+    public Date getEndBirthdayDate() {
+        return endBirthdayDate;
+    }
+
+    public void setEndBirthdayDate(Date endBirthdayDate) {
+        this.endBirthdayDate = endBirthdayDate;
+    }
+
+    public Date getBeginWorkDate() {
+        return beginWorkDate;
+    }
+
+    public void setBeginWorkDate(Date beginWorkDate) {
+        this.beginWorkDate = beginWorkDate;
+    }
+
+    public Date getEndWorkDate() {
+        return endWorkDate;
+    }
+
+    public void setEndWorkDate(Date endWorkDate) {
+        this.endWorkDate = endWorkDate;
+    }
+
+    public Integer getMinAge() {
+        return minAge;
+    }
+
+    public void setMinAge(Integer minAge) {
+        this.minAge = minAge;
+    }
+
+    public Integer getMaxAge() {
+        return maxAge;
+    }
+
+    public void setMaxAge(Integer maxAge) {
+        this.maxAge = maxAge;
+    }
+
+    public Double getMinSalary() {
+        return minSalary;
+    }
+
+    public void setMinSalary(Double minSalary) {
+        this.minSalary = minSalary;
+    }
+
+    public Double getMaxSalary() {
+        return maxSalary;
+    }
+
+    public void setMaxSalary(Double maxSalary) {
+        this.maxSalary = maxSalary;
+    }
+
+    public String getMinPercent() {
+        return minPercent;
+    }
+
+    public void setMinPercent(String minPercent) {
+        this.minPercent = minPercent;
+    }
+
+    public String getMaxPercent() {
+        return maxPercent;
+    }
+
+    public void setMaxPercent(String maxPercent) {
+        this.maxPercent = maxPercent;
+    }
+
+    public String getHome() {
+        return home;
+    }
+
+    public void setHome(String home) {
+        this.home = home;
+    }
+
+	public String getRoleId() {
+		return roleId;
+	}
+
+	public void setRoleId(String roleId) {
+		this.roleId = roleId;
+	}
+
+    @ExcelField(title="导入时间", align=2, sort=27)
+    public String getNowDate() {
+        return nowDate;
+    }
+
+    public void setNowDate(String nowDate) {
+        this.nowDate = nowDate;
+    }
+
+    @ExcelField(title="导入用户", align=2, sort=28)
+    public String getUserName() {
+        return userName;
+    }
+
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
+
+    @ExcelField(title="失败原因", align=2, sort=29)
+    public String getErrInfo() {
+        return errInfo;
+    }
+
+    public void setErrInfo(String errInfo) {
+        this.errInfo = errInfo;
+    }
+
+	public String getRoleName() {
+		return roleName;
+	}
+
+	public void setRoleName(String roleName) {
+		this.roleName = roleName;
+	}
+}

+ 160 - 0
src/main/java/com/jeeplus/modules/workstaff/entity/WorkStaffCertificate.java

@@ -0,0 +1,160 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workstaff.entity;
+
+import java.util.Date;
+import com.fasterxml.jackson.annotation.JsonFormat;
+
+import com.jeeplus.common.persistence.DataEntity;
+import com.jeeplus.common.utils.excel.annotation.ExcelField;
+import org.springframework.web.multipart.MultipartFile;
+
+/**
+ * 执业资格证书Entity
+ * @author ssrh
+ * @version 2018-07-27
+ */
+public class WorkStaffCertificate extends DataEntity<WorkStaffCertificate> {
+	
+	private static final long serialVersionUID = 1L;
+	private String staffId;		// 员工ID
+	private String name;		// 证书名称
+	private String num;		// 证书编号
+	private String issuingAuthority;		// 发证机关
+	private Date issuingDate;		// 发证日期
+	private Date registDate;		// 注册日期
+	private String registNum;		// 注册证书编号
+	private String major;		// 专业
+	private String grade;		// 等级
+	private String issType;		// 取得方式
+	private String filePath;		// 文件
+    private String fileName;		// 文件名
+    private MultipartFile file;
+
+    public String getFileName() {
+        return fileName;
+    }
+
+    public void setFileName(String fileName) {
+        this.fileName = fileName;
+    }
+
+    public MultipartFile getFile() {
+        return file;
+    }
+
+    public void setFile(MultipartFile file) {
+        this.file = file;
+    }
+
+    public WorkStaffCertificate() {
+		super();
+	}
+
+	public WorkStaffCertificate(String id){
+		super(id);
+	}
+
+	@ExcelField(title="员工ID", align=2, sort=7)
+	public String getStaffId() {
+		return staffId;
+	}
+
+	public void setStaffId(String staffId) {
+		this.staffId = staffId;
+	}
+	
+	@ExcelField(title="证书名称", align=2, sort=8)
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+	
+	@ExcelField(title="证书编号", align=2, sort=9)
+	public String getNum() {
+		return num;
+	}
+
+	public void setNum(String num) {
+		this.num = num;
+	}
+	
+	@ExcelField(title="发证机关", align=2, sort=10)
+	public String getIssuingAuthority() {
+		return issuingAuthority;
+	}
+
+	public void setIssuingAuthority(String issuingAuthority) {
+		this.issuingAuthority = issuingAuthority;
+	}
+	
+	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+	@ExcelField(title="发证日期", align=2, sort=11)
+	public Date getIssuingDate() {
+		return issuingDate;
+	}
+
+	public void setIssuingDate(Date issuingDate) {
+		this.issuingDate = issuingDate;
+	}
+	
+	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+	@ExcelField(title="注册日期", align=2, sort=12)
+	public Date getRegistDate() {
+		return registDate;
+	}
+
+	public void setRegistDate(Date registDate) {
+		this.registDate = registDate;
+	}
+	
+	@ExcelField(title="注册证书编号", align=2, sort=13)
+	public String getRegistNum() {
+		return registNum;
+	}
+
+	public void setRegistNum(String registNum) {
+		this.registNum = registNum;
+	}
+	
+	@ExcelField(title="专业", align=2, sort=14)
+	public String getMajor() {
+		return major;
+	}
+
+	public void setMajor(String major) {
+		this.major = major;
+	}
+	
+	@ExcelField(title="等级", align=2, sort=15)
+	public String getGrade() {
+		return grade;
+	}
+
+	public void setGrade(String grade) {
+		this.grade = grade;
+	}
+	
+	@ExcelField(title="取得方式", align=2, sort=16)
+	public String getIssType() {
+		return issType;
+	}
+
+	public void setIssType(String issType) {
+		this.issType = issType;
+	}
+	
+	@ExcelField(title="文件", align=2, sort=17)
+	public String getFilePath() {
+		return filePath;
+	}
+
+	public void setFilePath(String filePath) {
+		this.filePath = filePath;
+	}
+	
+}

+ 150 - 0
src/main/java/com/jeeplus/modules/workstaff/entity/WorkStaffEducation.java

@@ -0,0 +1,150 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workstaff.entity;
+
+import java.util.Date;
+import com.fasterxml.jackson.annotation.JsonFormat;
+
+import com.jeeplus.common.persistence.DataEntity;
+import com.jeeplus.common.utils.excel.annotation.ExcelField;
+import org.springframework.web.multipart.MultipartFile;
+
+/**
+ * 教育经历Entity
+ * @author ssrh
+ * @version 2018-07-27
+ */
+public class WorkStaffEducation extends DataEntity<WorkStaffEducation> {
+	
+	private static final long serialVersionUID = 1L;
+	private String staff;		// 员工ID
+	private String school;		// 毕业院校
+	private String major;		// 所学专业
+	private String edu;		// 学    历
+	private String degree;		// 学    位
+	private String eduType;		// 学历性质
+	private Date startDate;		// 入学日期
+	private Date endDate;		// 毕业日期
+	private String eduPhoto;		// 学历证书
+	private String degreePhoto;		// 学位证书
+    private MultipartFile degreePhotoFile;
+    private MultipartFile eduPhotoFile;
+
+    public MultipartFile getDegreePhotoFile() {
+        return degreePhotoFile;
+    }
+
+    public void setDegreePhotoFile(MultipartFile degreePhotoFile) {
+        this.degreePhotoFile = degreePhotoFile;
+    }
+
+    public MultipartFile getEduPhotoFile() {
+        return eduPhotoFile;
+    }
+
+    public void setEduPhotoFile(MultipartFile eduPhotoFile) {
+        this.eduPhotoFile = eduPhotoFile;
+    }
+
+    public WorkStaffEducation() {
+		super();
+	}
+
+	public WorkStaffEducation(String id){
+		super(id);
+	}
+
+	@ExcelField(title="员工ID", align=2, sort=7)
+	public String getStaff() {
+		return staff;
+	}
+
+	public void setStaff(String staff) {
+		this.staff = staff;
+	}
+	
+	@ExcelField(title="毕业院校", align=2, sort=8)
+	public String getSchool() {
+		return school;
+	}
+
+	public void setSchool(String school) {
+		this.school = school;
+	}
+	
+	@ExcelField(title="所学专业", align=2, sort=9)
+	public String getMajor() {
+		return major;
+	}
+
+	public void setMajor(String major) {
+		this.major = major;
+	}
+	
+	@ExcelField(title="学    历", dictType="", align=2, sort=10)
+	public String getEdu() {
+		return edu;
+	}
+
+	public void setEdu(String edu) {
+		this.edu = edu;
+	}
+	
+	@ExcelField(title="学    位", dictType="", align=2, sort=11)
+	public String getDegree() {
+		return degree;
+	}
+
+	public void setDegree(String degree) {
+		this.degree = degree;
+	}
+	
+	@ExcelField(title="学历性质", dictType="", align=2, sort=12)
+	public String getEduType() {
+		return eduType;
+	}
+
+	public void setEduType(String eduType) {
+		this.eduType = eduType;
+	}
+	
+	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+	@ExcelField(title="入学日期", align=2, sort=13)
+	public Date getStartDate() {
+		return startDate;
+	}
+
+	public void setStartDate(Date startDate) {
+		this.startDate = startDate;
+	}
+	
+	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+	@ExcelField(title="毕业日期", align=2, sort=14)
+	public Date getEndDate() {
+		return endDate;
+	}
+
+	public void setEndDate(Date endDate) {
+		this.endDate = endDate;
+	}
+	
+	@ExcelField(title="学历证书", align=2, sort=15)
+	public String getEduPhoto() {
+		return eduPhoto;
+	}
+
+	public void setEduPhoto(String eduPhoto) {
+		this.eduPhoto = eduPhoto;
+	}
+	
+	@ExcelField(title="学位证书", align=2, sort=16)
+	public String getDegreePhoto() {
+		return degreePhoto;
+	}
+
+	public void setDegreePhoto(String degreePhoto) {
+		this.degreePhoto = degreePhoto;
+	}
+	
+}

+ 111 - 0
src/main/java/com/jeeplus/modules/workstaff/entity/WorkStaffExperience.java

@@ -0,0 +1,111 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workstaff.entity;
+
+import java.util.Date;
+import com.fasterxml.jackson.annotation.JsonFormat;
+
+import com.jeeplus.common.persistence.DataEntity;
+import com.jeeplus.common.utils.excel.annotation.ExcelField;
+
+/**
+ * 工作经历Entity
+ * @author ssrh
+ * @version 2018-07-27
+ */
+public class WorkStaffExperience extends DataEntity<WorkStaffExperience> {
+	
+	private static final long serialVersionUID = 1L;
+	private String staffId;		// 员工ID
+	private String company;		// 所在单位
+	private String dept;		// 工作部门
+	private String duty;		// 职务或岗位
+	private Date startDate;		// 起始日期
+	private Date endDate;		// 终止日期
+	private String certifier;		// 证明人
+	private String certifierTel;		// 证明人联系方式
+	
+	public WorkStaffExperience() {
+		super();
+	}
+
+	public WorkStaffExperience(String id){
+		super(id);
+	}
+
+	@ExcelField(title="员工ID", align=2, sort=7)
+	public String getStaffId() {
+		return staffId;
+	}
+
+	public void setStaffId(String staffId) {
+		this.staffId = staffId;
+	}
+	
+	@ExcelField(title="所在单位", align=2, sort=8)
+	public String getCompany() {
+		return company;
+	}
+
+	public void setCompany(String company) {
+		this.company = company;
+	}
+	
+	@ExcelField(title="工作部门", align=2, sort=9)
+	public String getDept() {
+		return dept;
+	}
+
+	public void setDept(String dept) {
+		this.dept = dept;
+	}
+	
+	@ExcelField(title="职务或岗位", align=2, sort=10)
+	public String getDuty() {
+		return duty;
+	}
+
+	public void setDuty(String duty) {
+		this.duty = duty;
+	}
+	
+	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+	@ExcelField(title="起始日期", align=2, sort=11)
+	public Date getStartDate() {
+		return startDate;
+	}
+
+	public void setStartDate(Date startDate) {
+		this.startDate = startDate;
+	}
+	
+	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+	@ExcelField(title="终止日期", align=2, sort=12)
+	public Date getEndDate() {
+		return endDate;
+	}
+
+	public void setEndDate(Date endDate) {
+		this.endDate = endDate;
+	}
+	
+	@ExcelField(title="证明人", align=2, sort=13)
+	public String getCertifier() {
+		return certifier;
+	}
+
+	public void setCertifier(String certifier) {
+		this.certifier = certifier;
+	}
+	
+	@ExcelField(title="证明人联系方式", align=2, sort=14)
+	public String getCertifierTel() {
+		return certifierTel;
+	}
+
+	public void setCertifierTel(String certifierTel) {
+		this.certifierTel = certifierTel;
+	}
+	
+}

+ 87 - 0
src/main/java/com/jeeplus/modules/workstaff/entity/WorkStaffFamily.java

@@ -0,0 +1,87 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workstaff.entity;
+
+
+import com.jeeplus.common.persistence.DataEntity;
+import com.jeeplus.common.utils.excel.annotation.ExcelField;
+
+/**
+ * 家庭情况Entity
+ * @author ssrh
+ * @version 2018-07-27
+ */
+public class WorkStaffFamily extends DataEntity<WorkStaffFamily> {
+	
+	private static final long serialVersionUID = 1L;
+	private String staff;		// 员工ID
+	private String relation;		// 与本人的关系
+	private String name;		// 成员姓名
+	private String idCard;		// 身份证号码
+	private String gender;		// 成员性别
+	private String contact;		// 成员联系方式
+	
+	public WorkStaffFamily() {
+		super();
+	}
+
+	public WorkStaffFamily(String id){
+		super(id);
+	}
+
+	@ExcelField(title="员工ID", align=2, sort=7)
+	public String getStaff() {
+		return staff;
+	}
+
+	public void setStaff(String staff) {
+		this.staff = staff;
+	}
+	
+	@ExcelField(title="与本人的关系", align=2, sort=8)
+	public String getRelation() {
+		return relation;
+	}
+
+	public void setRelation(String relation) {
+		this.relation = relation;
+	}
+	
+	@ExcelField(title="成员姓名", align=2, sort=9)
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+	
+	@ExcelField(title="身份证号码", align=2, sort=10)
+	public String getIdCard() {
+		return idCard;
+	}
+
+	public void setIdCard(String idCard) {
+		this.idCard = idCard;
+	}
+	
+	@ExcelField(title="成员性别", dictType="", align=2, sort=11)
+	public String getGender() {
+		return gender;
+	}
+
+	public void setGender(String gender) {
+		this.gender = gender;
+	}
+	
+	@ExcelField(title="成员联系方式", align=2, sort=12)
+	public String getContact() {
+		return contact;
+	}
+
+	public void setContact(String contact) {
+		this.contact = contact;
+	}
+	
+}

+ 107 - 0
src/main/java/com/jeeplus/modules/workstaff/entity/WorkStaffLanguages.java

@@ -0,0 +1,107 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workstaff.entity;
+
+
+import com.jeeplus.common.persistence.DataEntity;
+import com.jeeplus.common.utils.excel.annotation.ExcelField;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.Date;
+
+/**
+ * 外语信息Entity
+ * @author ssrh
+ * @version 2018-07-27
+ */
+public class WorkStaffLanguages extends DataEntity<WorkStaffLanguages> {
+	
+	private static final long serialVersionUID = 1L;
+	private String staffId;		// 员工ID
+	private String language;		// 语种
+	private String proficiency;		// 熟练程度
+	private String certificate;		// 证书名称
+	private Date certifDate;		// 获证日期
+	private String filePath;		// 文件
+	private String fileName;		// 文件名
+    private MultipartFile file;
+
+	public WorkStaffLanguages() {
+		super();
+	}
+
+	public WorkStaffLanguages(String id){
+		super(id);
+	}
+
+	@ExcelField(title="员工ID", align=2, sort=7)
+	public String getStaffId() {
+		return staffId;
+	}
+
+	public void setStaffId(String staffId) {
+		this.staffId = staffId;
+	}
+	
+	@ExcelField(title="语种", align=2, sort=8)
+	public String getLanguage() {
+		return language;
+	}
+
+	public void setLanguage(String language) {
+		this.language = language;
+	}
+	
+	@ExcelField(title="熟练程度", align=2, sort=9)
+	public String getProficiency() {
+		return proficiency;
+	}
+
+	public void setProficiency(String proficiency) {
+		this.proficiency = proficiency;
+	}
+	
+	@ExcelField(title="证书名称", align=2, sort=10)
+	public String getCertificate() {
+		return certificate;
+	}
+
+	public void setCertificate(String certificate) {
+		this.certificate = certificate;
+	}
+	
+	@ExcelField(title="获证日期", align=2, sort=11)
+	public Date getCertifDate() {
+		return certifDate;
+	}
+
+	public void setCertifDate(Date certifDate) {
+		this.certifDate = certifDate;
+	}
+	
+	@ExcelField(title="文件", align=2, sort=12)
+	public String getFilePath() {
+		return filePath;
+	}
+
+	public void setFilePath(String filePath) {
+		this.filePath = filePath;
+	}
+
+    public String getFileName() {
+        return fileName;
+    }
+
+    public void setFileName(String fileName) {
+        this.fileName = fileName;
+    }
+
+    public MultipartFile getFile() {
+        return file;
+    }
+
+    public void setFile(MultipartFile file) {
+        this.file = file;
+    }
+}

+ 96 - 0
src/main/java/com/jeeplus/modules/workstaff/entity/WorkStaffRecord.java

@@ -0,0 +1,96 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workstaff.entity;
+
+
+import com.jeeplus.common.persistence.DataEntity;
+import com.jeeplus.common.utils.excel.annotation.ExcelField;
+import org.springframework.web.multipart.MultipartFile;
+
+/**
+ * 电子档案Entity
+ * @author ssrh
+ * @version 2018-07-27
+ */
+public class WorkStaffRecord extends DataEntity<WorkStaffRecord> {
+	
+	private static final long serialVersionUID = 1L;
+	private String staff;		// 员工ID
+	private String name;		// 档案名称
+	private String num;		// 编号
+	private String filePath;		// 文件
+	private String status;		// 验证
+    private String fileName;		// 文件名
+    private MultipartFile file;
+
+    public String getFileName() {
+        return fileName;
+    }
+
+    public void setFileName(String fileName) {
+        this.fileName = fileName;
+    }
+
+    public MultipartFile getFile() {
+        return file;
+    }
+
+    public void setFile(MultipartFile file) {
+        this.file = file;
+    }
+	
+	public WorkStaffRecord() {
+		super();
+	}
+
+	public WorkStaffRecord(String id){
+		super(id);
+	}
+
+	@ExcelField(title="员工ID", align=2, sort=7)
+	public String getStaff() {
+		return staff;
+	}
+
+	public void setStaff(String staff) {
+		this.staff = staff;
+	}
+	
+	@ExcelField(title="档案名称", align=2, sort=8)
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+	
+	@ExcelField(title="编号", align=2, sort=9)
+	public String getNum() {
+		return num;
+	}
+
+	public void setNum(String num) {
+		this.num = num;
+	}
+	
+	@ExcelField(title="文件", align=2, sort=10)
+	public String getFilePath() {
+		return filePath;
+	}
+
+	public void setFilePath(String filePath) {
+		this.filePath = filePath;
+	}
+	
+	@ExcelField(title="验证", dictType="", align=2, sort=11)
+	public String getStatus() {
+		return status;
+	}
+
+	public void setStatus(String status) {
+		this.status = status;
+	}
+	
+}

+ 97 - 0
src/main/java/com/jeeplus/modules/workstaff/entity/WorkStaffRewards.java

@@ -0,0 +1,97 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workstaff.entity;
+
+
+import com.jeeplus.common.persistence.DataEntity;
+import com.jeeplus.common.utils.excel.annotation.ExcelField;
+
+/**
+ * 奖惩情况Entity
+ * @author ssrh
+ * @version 2018-07-27
+ */
+public class WorkStaffRewards extends DataEntity<WorkStaffRewards> {
+	
+	private static final long serialVersionUID = 1L;
+	private String staff;		// 员工ID
+	private String type;		// 奖惩类型
+	private String name;		// 奖惩名称
+	private String atTime;		// 时间
+	private String grade;		// 级别
+	private String reason;		// 原因
+	private String organization;		// 授予机构
+	
+	public WorkStaffRewards() {
+		super();
+	}
+
+	public WorkStaffRewards(String id){
+		super(id);
+	}
+
+	@ExcelField(title="员工ID", align=2, sort=7)
+	public String getStaff() {
+		return staff;
+	}
+
+	public void setStaff(String staff) {
+		this.staff = staff;
+	}
+	
+	@ExcelField(title="奖惩类型", dictType="", align=2, sort=8)
+	public String getType() {
+		return type;
+	}
+
+	public void setType(String type) {
+		this.type = type;
+	}
+	
+	@ExcelField(title="奖惩名称", align=2, sort=9)
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+	
+	@ExcelField(title="时间", align=2, sort=10)
+	public String getAtTime() {
+		return atTime;
+	}
+
+	public void setAtTime(String atTime) {
+		this.atTime = atTime;
+	}
+	
+	@ExcelField(title="级别", align=2, sort=11)
+	public String getGrade() {
+		return grade;
+	}
+
+	public void setGrade(String grade) {
+		this.grade = grade;
+	}
+	
+	@ExcelField(title="原因", align=2, sort=12)
+	public String getReason() {
+		return reason;
+	}
+
+	public void setReason(String reason) {
+		this.reason = reason;
+	}
+	
+	@ExcelField(title="授予机构", align=2, sort=13)
+	public String getOrganization() {
+		return organization;
+	}
+
+	public void setOrganization(String organization) {
+		this.organization = organization;
+	}
+	
+}

+ 81 - 0
src/main/java/com/jeeplus/modules/workstaff/entity/WorkStaffSocialPosition.java

@@ -0,0 +1,81 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workstaff.entity;
+
+import com.jeeplus.modules.sys.entity.User;
+import java.util.Date;
+import com.fasterxml.jackson.annotation.JsonFormat;
+
+import com.jeeplus.common.persistence.DataEntity;
+import com.jeeplus.common.utils.excel.annotation.ExcelField;
+
+/**
+ * 社会及行业职务Entity
+ * @author ssrh
+ * @version 2018-07-27
+ */
+public class WorkStaffSocialPosition extends DataEntity<WorkStaffSocialPosition> {
+	
+	private static final long serialVersionUID = 1L;
+	private String staff;		// 员工ID
+	private String name;		// 职务名称
+	private Date startDate;		// 任职开始日期
+	private Date endDate;		// 任职结束日期
+	private String organization;		// 任职机构
+	
+	public WorkStaffSocialPosition() {
+		super();
+	}
+
+	public WorkStaffSocialPosition(String id){
+		super(id);
+	}
+
+	@ExcelField(title="员工ID", align=2, sort=7)
+	public String getStaff() {
+		return staff;
+	}
+
+	public void setStaff(String staff) {
+		this.staff = staff;
+	}
+	
+	@ExcelField(title="职务名称", align=2, sort=8)
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+	
+	@ExcelField(title="任职开始日期", align=2, sort=9)
+	public Date getStartDate() {
+		return startDate;
+	}
+
+	public void setStartDate(Date startDate) {
+		this.startDate = startDate;
+	}
+	
+	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+	@ExcelField(title="任职结束日期", align=2, sort=10)
+	public Date getEndDate() {
+		return endDate;
+	}
+
+	public void setEndDate(Date endDate) {
+		this.endDate = endDate;
+	}
+	
+	@ExcelField(title="任职机构", align=2, sort=11)
+	public String getOrganization() {
+		return organization;
+	}
+
+	public void setOrganization(String organization) {
+		this.organization = organization;
+	}
+	
+}

+ 118 - 0
src/main/java/com/jeeplus/modules/workstaff/entity/WorkStaffTitle.java

@@ -0,0 +1,118 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workstaff.entity;
+
+
+import com.jeeplus.common.persistence.DataEntity;
+import com.jeeplus.common.utils.excel.annotation.ExcelField;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.Date;
+
+/**
+ * 职称Entity
+ * @author ssrh
+ * @version 2018-07-27
+ */
+public class WorkStaffTitle extends DataEntity<WorkStaffTitle> {
+	
+	private static final long serialVersionUID = 1L;
+	private String staffId;		// 员工ID
+	private String name;		// 职称名称
+	private String grade;		// 职称等级
+	private Date startDate;		// 取得日期
+	private String pathway;		// 取得途径
+	private String approvalAuthority;		// 审批单位
+	private String filePath;		// 文件
+    private String fileName;		// 文件名
+    private MultipartFile file;
+
+    public String getFileName() {
+        return fileName;
+    }
+
+    public void setFileName(String fileName) {
+        this.fileName = fileName;
+    }
+
+    public MultipartFile getFile() {
+        return file;
+    }
+
+    public void setFile(MultipartFile file) {
+        this.file = file;
+    }
+	
+	public WorkStaffTitle() {
+		super();
+	}
+
+	public WorkStaffTitle(String id){
+		super(id);
+	}
+
+	@ExcelField(title="员工ID", align=2, sort=7)
+	public String getStaffId() {
+		return staffId;
+	}
+
+	public void setStaffId(String staffId) {
+		this.staffId = staffId;
+	}
+	
+	@ExcelField(title="职称名称", align=2, sort=8)
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+	
+	@ExcelField(title="职称等级", align=2, sort=9)
+	public String getGrade() {
+		return grade;
+	}
+
+	public void setGrade(String grade) {
+		this.grade = grade;
+	}
+	
+	@ExcelField(title="取得日期", align=2, sort=10)
+	public Date getStartDate() {
+		return startDate;
+	}
+
+	public void setStartDate(Date startDate) {
+		this.startDate = startDate;
+	}
+	
+	@ExcelField(title="取得途径", align=2, sort=11)
+	public String getPathway() {
+		return pathway;
+	}
+
+	public void setPathway(String pathway) {
+		this.pathway = pathway;
+	}
+	
+	@ExcelField(title="审批单位", align=2, sort=12)
+	public String getApprovalAuthority() {
+		return approvalAuthority;
+	}
+
+	public void setApprovalAuthority(String approvalAuthority) {
+		this.approvalAuthority = approvalAuthority;
+	}
+	
+	@ExcelField(title="文件", align=2, sort=13)
+	public String getFilePath() {
+		return filePath;
+	}
+
+	public void setFilePath(String filePath) {
+		this.filePath = filePath;
+	}
+	
+}

+ 148 - 0
src/main/java/com/jeeplus/modules/workstaff/entity/WorkStaffTraining.java

@@ -0,0 +1,148 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workstaff.entity;
+
+
+import com.jeeplus.common.persistence.DataEntity;
+import com.jeeplus.common.utils.excel.annotation.ExcelField;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.Date;
+
+/**
+ * 培训经历Entity
+ * @author ssrh
+ * @version 2018-07-27
+ */
+public class WorkStaffTraining extends DataEntity<WorkStaffTraining> {
+	
+	private static final long serialVersionUID = 1L;
+	private String staff;		// 员工ID
+	private String name;		// 培训名称
+	private String agency;		// 培训机构
+	private String address;		// 培训地点
+	private Date startDate;		// 培训起始日期
+	private Date endDate;		// 培训终止日期
+	private String type;		// 培训类型
+	private String hours;		// 学时
+	private String certificate;		// 所获证书
+	private String filePath;		// 文件
+    private String fileName;		// 文件名
+    private MultipartFile file;
+
+    public String getFileName() {
+        return fileName;
+    }
+
+    public void setFileName(String fileName) {
+        this.fileName = fileName;
+    }
+
+    public MultipartFile getFile() {
+        return file;
+    }
+
+    public void setFile(MultipartFile file) {
+        this.file = file;
+    }
+	
+	public WorkStaffTraining() {
+		super();
+	}
+
+	public WorkStaffTraining(String id){
+		super(id);
+	}
+
+	@ExcelField(title="员工ID", align=2, sort=7)
+	public String getStaff() {
+		return staff;
+	}
+
+	public void setStaff(String staff) {
+		this.staff = staff;
+	}
+	
+	@ExcelField(title="培训名称", align=2, sort=8)
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+	
+	@ExcelField(title="培训机构", align=2, sort=9)
+	public String getAgency() {
+		return agency;
+	}
+
+	public void setAgency(String agency) {
+		this.agency = agency;
+	}
+	
+	@ExcelField(title="培训地点", align=2, sort=10)
+	public String getAddress() {
+		return address;
+	}
+
+	public void setAddress(String address) {
+		this.address = address;
+	}
+	
+	@ExcelField(title="培训起始日期", align=2, sort=11)
+	public Date getStartDate() {
+		return startDate;
+	}
+
+	public void setStartDate(Date startDate) {
+		this.startDate = startDate;
+	}
+	
+	@ExcelField(title="培训终止日期", align=2, sort=12)
+	public Date getEndDate() {
+		return endDate;
+	}
+
+	public void setEndDate(Date endDate) {
+		this.endDate = endDate;
+	}
+	
+	@ExcelField(title="培训类型", dictType="", align=2, sort=13)
+	public String getType() {
+		return type;
+	}
+
+	public void setType(String type) {
+		this.type = type;
+	}
+	
+	@ExcelField(title="学时", align=2, sort=14)
+	public String getHours() {
+		return hours;
+	}
+
+	public void setHours(String hours) {
+		this.hours = hours;
+	}
+	
+	@ExcelField(title="所获证书", align=2, sort=15)
+	public String getCertificate() {
+		return certificate;
+	}
+
+	public void setCertificate(String certificate) {
+		this.certificate = certificate;
+	}
+	
+	@ExcelField(title="文件", align=2, sort=16)
+	public String getFilePath() {
+		return filePath;
+	}
+
+	public void setFilePath(String filePath) {
+		this.filePath = filePath;
+	}
+	
+}

+ 378 - 0
src/main/java/com/jeeplus/modules/workstaff/service/WorkStaffAchievementService.java

@@ -0,0 +1,378 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workstaff.service;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.jeeplus.common.utils.IdGen;
+import com.jeeplus.common.utils.StringUtils;
+import com.jeeplus.modules.sys.dao.UserDao;
+import com.jeeplus.modules.sys.entity.User;
+import com.jeeplus.modules.sys.utils.DictUtils;
+import com.jeeplus.modules.workstaff.entity.WorkStaffBasicInfo;
+import com.jeeplus.modules.workstaff.entity.WorkStaffLanguages;
+import com.jeeplus.modules.workstaffachiveslog.entity.WorkStaffAchivesLog;
+import com.jeeplus.modules.workstaffachiveslog.service.WorkStaffAchivesLogService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.jeeplus.common.persistence.Page;
+import com.jeeplus.common.service.CrudService;
+import com.jeeplus.modules.workstaff.entity.WorkStaffAchievement;
+import com.jeeplus.modules.workstaff.dao.WorkStaffAchievementDao;
+import org.springframework.web.multipart.MultipartFile;
+
+/**
+ * 工作业绩Service
+ * @author ssrh
+ * @version 2018-07-27
+ */
+@Service
+@Transactional(readOnly = true)
+public class WorkStaffAchievementService extends CrudService<WorkStaffAchievementDao, WorkStaffAchievement> {
+    @Autowired
+    private WorkStaffAchivesLogService workStaffAchivesLogService;
+    @Autowired
+    private UserDao userDao;
+	public WorkStaffAchievement get(String id) {
+		return super.get(id);
+	}
+	
+	public List<WorkStaffAchievement> findList(WorkStaffAchievement workStaffAchievement) {
+		return super.findList(workStaffAchievement);
+	}
+	
+	public Page<WorkStaffAchievement> findPage(Page<WorkStaffAchievement> page, WorkStaffAchievement workStaffAchievement) {
+		return super.findPage(page, workStaffAchievement);
+	}
+	
+	@Transactional(readOnly = false)
+	public void save(WorkStaffAchievement workStaffAchievement) {
+		super.save(workStaffAchievement);
+	}
+	
+	@Transactional(readOnly = false)
+	public void delete(WorkStaffAchievement workStaffAchievement) {
+		super.delete(workStaffAchievement);
+	}
+
+
+    public boolean save(WorkStaffBasicInfo workStaffBasicInfo,boolean first) {
+        if(workStaffBasicInfo==null || StringUtils.isBlank(workStaffBasicInfo.getId())){
+            return false;
+        }
+        if(workStaffBasicInfo.getAchievementList()==null||workStaffBasicInfo.getAchievementList().size()<=0){
+            return false;
+        }
+        boolean flag = false;
+        for (WorkStaffAchievement entity : workStaffBasicInfo.getAchievementList()) {
+            if(entity!=null&&"1".equals(entity.getDelFlag())&&StringUtils.isBlank(entity.getId())){
+                continue;
+            }
+            if(entity!=null&&"1".equals(entity.getDelFlag())){
+                dao.deleteByLogic(entity);
+                continue;
+            }
+            if(entity!=null){
+                entity.setStaff(workStaffBasicInfo.getId());
+                this.save(entity);
+                if(first){
+                    entity.setId(null);
+                }
+                flag =true;
+            }
+        }
+        return flag;
+    }
+
+    public void query(WorkStaffBasicInfo workStaffBasicInfo) {
+        if(workStaffBasicInfo==null|| StringUtils.isBlank(workStaffBasicInfo.getId())){
+            return;
+        }
+        WorkStaffAchievement entity = new WorkStaffAchievement();
+        entity.setStaff(workStaffBasicInfo.getId());
+        workStaffBasicInfo.setAchievementList(this.findList(entity));
+    }
+    private static Map<String,String> EDU_MAP = Maps.newHashMap();//教育经历
+
+    static{//教育经历
+        EDU_MAP.put("projName", "项目名称");
+        EDU_MAP.put("projClient", "主委托方");
+        EDU_MAP.put("category", "工程分类");
+        EDU_MAP.put("unitNumber", "规模类型/单位/数量");
+        EDU_MAP.put("duty", "担任职务");
+        EDU_MAP.put("content", "参与内容");
+    }
+
+    public boolean saveApply(WorkStaffBasicInfo workStaffBasicInfo,boolean first) {
+        if(workStaffBasicInfo==null|| StringUtils.isBlank(workStaffBasicInfo.getId())){
+            return false;
+        }
+        List<WorkStaffAchievement> list = workStaffBasicInfo.getAchievementList();
+        if(list==null||list.size()<=0){
+            return false;
+        }
+        boolean flag = false;
+        User u=userDao.get(workStaffBasicInfo.getUserId());
+        for (WorkStaffAchievement entity : list) {
+            entity.setStaff(workStaffBasicInfo.getId());
+            WorkStaffAchievement workStaffLanguages=dao.get(entity.getId());
+            if(workStaffLanguages==null){
+                entity.setCreateBy(u);
+                entity.setCreateDate(new Date());
+                entity.setUpdateBy(u);
+                entity.setUpdateDate(new Date());
+                dao.insert(entity);
+            }else{
+                this.save(entity);
+            }
+            if(entity!=null&&"1".equals(entity.getDelFlag())){
+                dao.deleteByLogic(entity);
+                continue;
+            }
+            flag =true;
+        }
+        dao.updateFalt(workStaffBasicInfo.getId());
+        return flag;
+    }
+    public void querys(WorkStaffBasicInfo workStaffBasicInfo) {
+        SimpleDateFormat dateFormat1 = new SimpleDateFormat("yyyy-MM-dd");
+        if(workStaffBasicInfo==null|| StringUtils.isBlank(workStaffBasicInfo.getId())){
+            return;
+        }
+        WorkStaffAchievement entity = new WorkStaffAchievement();
+        entity.setStaff(workStaffBasicInfo.getId());
+        List<WorkStaffAchievement> list=this.findList(entity);
+        List<WorkStaffAchievement> newList=Lists.newArrayList();
+        if(list!=null&&list.size()>0){//修改
+            for(WorkStaffAchievement workStaffAchievement:list){
+                Class<? extends WorkStaffAchievement> newClass = workStaffAchievement.getClass();
+                Field[] declaredFields = newClass.getDeclaredFields();
+                for (Field field : declaredFields) {
+                    String name = field.getName();
+                    if("projName".equals(name)||"projClient".equals(name)||"category".equals(name)||"unitNumber".equals(name)||"duty".equals(name)
+                            || "content".equals(name)){
+                        String setMethod = "set"+name.substring(0,1).toUpperCase()+name.substring(1);
+                        String getMethod = "get"+name.substring(0,1).toUpperCase()+name.substring(1);
+                        WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+                        workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+                        workStaffAchivesLog.setModule("工作业绩");
+                        workStaffAchivesLog.setSonId(workStaffAchievement.getId());
+                        workStaffAchivesLog.setFields(name);
+                        workStaffAchivesLog.setType("修改");
+                        workStaffAchivesLog.setState("1");
+                        List<WorkStaffAchivesLog> logs=workStaffAchivesLogService.findList(workStaffAchivesLog);
+                        try {
+                            Object newInvoke = newClass.getMethod(getMethod).invoke(workStaffAchievement);//修改后
+                            if(newInvoke instanceof String){
+                                Method setReadOnly = workStaffAchievement.getClass().getMethod(setMethod, String.class);
+                                if(logs!=null&&logs.size()>0){
+                                    setReadOnly.invoke(workStaffAchievement,logs.get(0).getNewKey());
+                                }
+                            }
+                            if(newInvoke instanceof Date){//日期
+                                Method setReadOnly = workStaffAchievement.getClass().getMethod(setMethod, Date.class);
+                                if(logs!=null&&logs.size()>0){
+                                    Date myDate = dateFormat1.parse(logs.get(0).getNewKey());
+                                    setReadOnly.invoke(workStaffAchievement,myDate);
+                                }
+                            }
+                        } catch (NoSuchMethodException e) {
+                            e.printStackTrace();
+                        } catch (IllegalAccessException e) {
+                            e.printStackTrace();
+                        } catch (InvocationTargetException e) {
+                            e.printStackTrace();
+                        } catch (ParseException e) {
+                            e.printStackTrace();
+                        }
+                    }
+                }
+                newList.add(workStaffAchievement);
+            }
+        }
+        //新增
+        WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+        workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+        workStaffAchivesLog.setModule("工作业绩");
+        workStaffAchivesLog.setType("新增");
+        workStaffAchivesLog.setState("1");
+        List<WorkStaffAchivesLog> sonIds=workStaffAchivesLogService.findSonId(workStaffAchivesLog);
+        if(sonIds!=null&&sonIds.size()>0){
+            for(WorkStaffAchivesLog w:sonIds){
+                workStaffAchivesLog.setSonId(w.getSonId());
+                WorkStaffAchievement workStaffAchievement = new WorkStaffAchievement();
+                workStaffAchievement.setId(w.getSonId());
+                workStaffAchievement.setDelFlag("0");
+                workStaffAchievement.setStaff(workStaffBasicInfo.getId());
+                Class<? extends WorkStaffAchievement> newClass = workStaffAchievement.getClass();
+                Field[] declaredFields = newClass.getDeclaredFields();
+                for (Field field : declaredFields) {
+                    String name = field.getName();
+                    if("projName".equals(name)||"projClient".equals(name)||"category".equals(name)||"unitNumber".equals(name)||"duty".equals(name)
+                            || "content".equals(name)){
+                        String setMethod = "set"+name.substring(0,1).toUpperCase()+name.substring(1);
+                        String getMethod = "get"+name.substring(0,1).toUpperCase()+name.substring(1);
+                        workStaffAchivesLog.setFields(name);
+                        List<WorkStaffAchivesLog> logs=workStaffAchivesLogService.findList(workStaffAchivesLog);
+                        try {
+                                Method setReadOnly = workStaffAchievement.getClass().getMethod(setMethod, String.class);
+                                if(logs!=null&&logs.size()>0){
+                                    setReadOnly.invoke(workStaffAchievement,logs.get(0).getNewKey());
+                                }
+                        } catch (NoSuchMethodException e) {
+                            e.printStackTrace();
+                        } catch (IllegalAccessException e) {
+                            e.printStackTrace();
+                        } catch (InvocationTargetException e) {
+                            e.printStackTrace();
+                        }
+                    }
+                }
+                newList.add(workStaffAchievement);
+            }
+        }
+        //删除
+        WorkStaffAchivesLog delLog=new WorkStaffAchivesLog();
+        delLog.setStaffId(workStaffBasicInfo.getId());
+        delLog.setModule("工作业绩");
+        delLog.setType("删除");
+        workStaffAchivesLog.setState("1");
+        List<WorkStaffAchivesLog> dellogs=workStaffAchivesLogService.findList(delLog);
+        if(dellogs!=null&&dellogs.size()>0){
+            for(WorkStaffAchivesLog w:dellogs){
+                newList.remove(dao.get(w.getSonId()));
+            }
+        }
+        workStaffBasicInfo.setAchievementList(newList);
+    }
+    @Transactional(readOnly = false)
+    public void saveEdu(WorkStaffBasicInfo workStaffBasicInfo) {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        List<WorkStaffAchievement> achievementList =workStaffBasicInfo.getAchievementList();
+        if(achievementList!=null&&achievementList.size()>0){
+            for(WorkStaffAchievement newAchievement:achievementList){
+                Class<? extends WorkStaffAchievement> newClass = newAchievement.getClass();
+                Field[] declaredFields = newClass.getDeclaredFields();
+                if(newAchievement.getId()!=null&&!"1".equals(newAchievement.getDelFlag())&&!"".equals(newAchievement.getId())){
+                    WorkStaffAchievement oldAchievement=this.get(newAchievement.getId());
+                    if(oldAchievement!=null){
+                        Class<? extends WorkStaffAchievement> oldClass = oldAchievement.getClass();
+                        for (Field field : declaredFields) {
+                            String name = field.getName();
+                            if("projName".equals(name)||"projClient".equals(name)||"category".equals(name)||"unitNumber".equals(name)||"duty".equals(name)
+                                    || "content".equals(name)){
+                                String methodName = "get"+name.substring(0,1).toUpperCase()+name.substring(1);
+                                WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+                                workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+                                workStaffAchivesLog.setModule("工作业绩");
+                                workStaffAchivesLog.setSonId(newAchievement.getId());
+                                workStaffAchivesLog.setFields(name);
+                                workStaffAchivesLog.setState("1");
+                                try {
+                                    Object newInvoke = newClass.getMethod(methodName).invoke(newAchievement);//修改后
+                                    Object oldInvoke = oldClass.getMethod(methodName).invoke(oldAchievement);//修改前
+                                    String describes=EDU_MAP.get(name);
+                                    if(newInvoke instanceof String){
+                                        String newValue=newInvoke.toString();
+                                        String oldValue=oldInvoke.toString();
+                                        if(!newValue.equals(oldValue)){
+                                                workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                                        "工作业绩",describes,name,
+                                                        oldInvoke.toString(),newInvoke.toString(),
+                                                        oldInvoke.toString(),newInvoke.toString(),newAchievement.getId(),"修改");
+
+                                        }
+                                    }
+                                    if(newInvoke instanceof Date){//日期
+                                        String newDate="";
+                                        String oldDate="";
+                                        if(newInvoke!=null){
+                                            newDate=sdf.format(newInvoke);
+                                        }
+                                        if (oldInvoke!=null){
+                                            oldDate=sdf.format(oldInvoke);
+                                        }
+                                        if(!newDate.equals(oldDate)){
+                                            workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                                    "工作业绩",describes,name,
+                                                    oldDate,newDate,oldDate,newDate,newAchievement.getId(),"修改");
+                                        }
+                                    }
+                                } catch (NoSuchMethodException e) {
+                                    e.printStackTrace();
+                                } catch (IllegalAccessException e) {
+                                    e.printStackTrace();
+                                } catch (InvocationTargetException e) {
+                                    e.printStackTrace();
+                                }
+                            }
+                        }
+
+                    }
+                }else if((newAchievement.getId()==null||"".equals(newAchievement.getId()))&&"0".equals(newAchievement.getDelFlag())){//新增
+                    String newId=IdGen.uuid();
+                    for (Field field : declaredFields) {
+                        String name = field.getName();
+                        if("projName".equals(name)||"projClient".equals(name)||"category".equals(name)||"unitNumber".equals(name)||"duty".equals(name)
+                                || "content".equals(name)){
+                            String methodName = "get"+name.substring(0,1).toUpperCase()+name.substring(1);
+                            WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+                            workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+                            workStaffAchivesLog.setModule("工作业绩");
+                            workStaffAchivesLog.setSonId(newId);
+                            workStaffAchivesLog.setFields(name);
+                            workStaffAchivesLog.setState("1");
+                            try {
+                                Object newInvoke = newClass.getMethod(methodName).invoke(newAchievement);//修改后
+                                String describes=EDU_MAP.get(name);
+                                if(newInvoke instanceof String){
+                                    String newValue=newInvoke.toString();
+                                        workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                                "工作业绩",describes,name,
+                                                "",newInvoke.toString(),
+                                                "",newInvoke.toString(),newId,"新增");
+
+                                }
+                                if(newInvoke instanceof Date){//日期
+                                    String newDate=sdf.format(newInvoke);
+                                    workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                            "工作业绩",describes,name,
+                                            "",newDate,"",newDate,newId,"新增");
+                                };
+                            } catch (NoSuchMethodException e) {
+                                e.printStackTrace();
+                            } catch (IllegalAccessException e) {
+                                e.printStackTrace();
+                            } catch (InvocationTargetException e) {
+                                e.printStackTrace();
+                            }
+                        }
+                    }
+                }else if(newAchievement.getId()!=null&&"1".equals(newAchievement.getDelFlag())&&!"".equals(newAchievement.getId())){//删除
+                    WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+                    workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+                    workStaffAchivesLog.setModule("工作业绩");
+                    workStaffAchivesLog.setSonId(newAchievement.getId());
+                    workStaffAchivesLog.setType("删除");
+                    workStaffAchivesLog.setState("1");
+                    workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                            "工作业绩","","",
+                            "","",
+                            "","",newAchievement.getId(),"删除");
+                }
+            }
+        }
+    }
+}

+ 929 - 0
src/main/java/com/jeeplus/modules/workstaff/service/WorkStaffBasicInfoService.java

@@ -0,0 +1,929 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workstaff.service;
+
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.math.BigDecimal;
+import java.text.NumberFormat;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.jeeplus.common.bos.BOSClientUtil;
+import com.jeeplus.common.config.Global;
+import com.jeeplus.common.oss.OSSClientUtil;
+import com.jeeplus.common.utils.FileUtils;
+import com.jeeplus.common.utils.IdGen;
+import com.jeeplus.common.utils.MenuStatusEnum;
+import com.jeeplus.common.utils.StringUtils;
+import com.jeeplus.modules.sys.dao.AreaDao;
+import com.jeeplus.modules.sys.dao.UserDao;
+import com.jeeplus.modules.sys.entity.Area;
+import com.jeeplus.modules.sys.entity.Office;
+import com.jeeplus.modules.sys.entity.Role;
+import com.jeeplus.modules.sys.entity.User;
+import com.jeeplus.modules.sys.service.OfficeService;
+import com.jeeplus.modules.sys.service.RoleService;
+import com.jeeplus.modules.sys.service.SystemService;
+import com.jeeplus.modules.sys.service.UserService;
+import com.jeeplus.modules.sys.utils.DictUtils;
+import com.jeeplus.modules.sys.utils.UserUtils;
+import com.jeeplus.modules.sysuseroffice.entity.Useroffice;
+import com.jeeplus.modules.sysuseroffice.service.UserofficeService;
+import com.jeeplus.modules.workclientinfo.dao.WorkClientAttachmentDao;
+import com.jeeplus.modules.workclientinfo.entity.WorkClientAttachment;
+import com.jeeplus.modules.workprojectnotify.entity.WorkProjectNotify;
+import com.jeeplus.modules.workprojectnotify.service.WorkProjectNotifyService;
+import com.jeeplus.modules.workprojectnotify.util.UtilNotify;
+import com.jeeplus.modules.workrelationship.dao.WorkRelationshipDao;
+import com.jeeplus.modules.workrelationship.entity.WorkRelationship;
+import com.jeeplus.modules.workstaff.dao.*;
+import com.jeeplus.modules.workstaff.entity.*;
+import com.jeeplus.modules.workstaffachiveslog.dao.WorkStaffAchivesLogDao;
+import com.jeeplus.modules.workstaffachiveslog.entity.WorkStaffAchivesLog;
+import com.jeeplus.modules.workstaffachiveslog.service.WorkStaffAchivesLogService;
+import com.sun.corba.se.spi.orbutil.threadpool.Work;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.jeeplus.common.persistence.Page;
+import com.jeeplus.common.service.CrudService;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * 员工基本信息Service
+ * @author ssrh
+ * @version 2018-07-26
+ */
+@Service
+@Transactional(readOnly = true)
+public class WorkStaffBasicInfoService extends CrudService<WorkStaffBasicInfoDao, WorkStaffBasicInfo> {
+
+    @Autowired
+    private  RoleService roleService;
+    @Autowired
+    private WorkStaffAchievementService achievementService;
+    @Autowired
+    private WorkStaffCertificateService certificateService;
+    @Autowired
+    private WorkStaffEducationService educationService;
+    @Autowired
+    private WorkStaffExperienceService experienceService;
+    @Autowired
+    private WorkStaffFamilyService familyService;
+    @Autowired
+    private WorkStaffLanguagesService languagesService;
+    @Autowired
+    private WorkStaffRecordService recordService;
+    @Autowired
+    private WorkStaffRewardsService rewardsService;
+    @Autowired
+    private WorkStaffSocialPositionService socialPositionService;
+    @Autowired
+    private WorkStaffTitleService titleService;
+    @Autowired
+    private WorkStaffTrainingService trainingService;
+    @Autowired
+    private UserService userService;
+    @Autowired
+    private WorkStaffBasicInfoDao workStaffBasicInfoDao;
+    @Autowired
+    private WorkRelationshipDao workRelationshipDao;
+    @Autowired
+    private WorkProjectNotifyService workProjectNotifyService;
+    @Autowired
+    private WorkStaffAchivesDao workStaffAchivesDao;
+    @Autowired
+    private WorkClientAttachmentDao workClientAttachmentDao;
+    @Autowired
+    private UserofficeService userofficeService;
+    @Autowired
+    private SystemService systemService;
+    @Autowired
+    private OfficeService officeService;
+    @Autowired
+    private WorkStaffAchivesLogDao workStaffAchivesLogDao;
+    @Autowired
+    private WorkStaffAchivesLogService workStaffAchivesLogService;
+    @Autowired
+    private AreaDao areaDao;
+    @Autowired
+    private WorkStaffEducationDao educationDao;
+    @Autowired
+    private WorkStaffLanguagesDao languagesDao;
+    @Autowired
+    private WorkStaffAchievementDao achievementDao;
+    @Autowired
+    private WorkStaffCertificateDao certificateDao;
+    @Autowired
+    private WorkStaffExperienceDao experienceDao;
+    @Autowired
+    private WorkStaffFamilyDao familyDao;
+    @Autowired
+    private WorkStaffRecordDao recordDao;
+    @Autowired
+    private WorkStaffRewardsDao rewardsDao;
+    @Autowired
+    private WorkStaffSocialPositionDao socialPositionDao;
+    @Autowired
+    private WorkStaffTitleDao titleDao;
+    @Autowired
+    private WorkStaffTrainingDao trainingDao;
+
+
+    public WorkStaffBasicInfo get(String id) {
+		return super.get(id);
+	}
+	public Integer getByCompany(WorkStaffBasicInfo workStaffBasicInfo) {
+	  return workStaffAchivesDao.getByCompany(workStaffBasicInfo);
+	}
+	public List<WorkStaffBasicInfo> getByCompanyInfo(WorkStaffBasicInfo workStaffBasicInfo) {
+        return workStaffAchivesDao.getByCompanyInfo(workStaffBasicInfo);
+    }
+
+    public List<WorkStaffBasicInfo> findByMob(WorkStaffBasicInfo workStaffBasicInfo) {
+        return workStaffBasicInfoDao.findByMob(workStaffBasicInfo);
+    }
+
+    public List<WorkStaffBasicInfo> findByName(String name) {
+        return workStaffBasicInfoDao.findByName(name);
+    }
+    public WorkStaffBasicInfo getByUserOffice(WorkStaffBasicInfo workStaffBasicInfo) {
+        return workStaffAchivesDao.getByUserOffice(workStaffBasicInfo);
+    }
+    //根据工号及名称获取信息
+    public WorkStaffBasicInfo getByNoName(WorkStaffBasicInfo workStaffBasicInfo) {
+        return workStaffAchivesDao.getByNoName(workStaffBasicInfo);
+    }
+	//档案表
+    public WorkStaffBasicInfo getAchives(String id) {
+        return workStaffAchivesDao.get(id);
+    }
+	public List<WorkStaffBasicInfo> findList(WorkStaffBasicInfo workStaffBasicInfo) {
+        if(!UserUtils.getUser().isAdmin()) {
+            String dataScopeSql = dataScopeFilterOR(workStaffBasicInfo.getCurrentUser(), "o", "u", "s", MenuStatusEnum.WORK_STAFFBASICINFO.getValue());
+            workStaffBasicInfo.getSqlMap().put("dsf", dataScopeSql);
+            if(workStaffBasicInfo.getCurrentUser().getBranchOffice()==null){
+                workStaffBasicInfo.getCurrentUser().setBranchOffice(workStaffBasicInfo.getCurrentUser().getCompany());
+            }
+        }
+		return super.findList(workStaffBasicInfo);
+	}
+	
+	public Page<WorkStaffBasicInfo> findPage(Page<WorkStaffBasicInfo> page, WorkStaffBasicInfo workStaffBasicInfo) {
+        if(!UserUtils.getUser().isAdmin()) {
+            String dataScopeSql = dataScopeFilterOR(workStaffBasicInfo.getCurrentUser(), "o", "u", "s", MenuStatusEnum.WORK_STAFFBASICINFO.getValue());
+            workStaffBasicInfo.getSqlMap().put("dsf", dataScopeSql);
+            if(workStaffBasicInfo.getCurrentUser().getBranchOffice()==null){
+                workStaffBasicInfo.getCurrentUser().setBranchOffice(workStaffBasicInfo.getCurrentUser().getCompany());
+            }
+        }
+		return super.findPage(page, workStaffBasicInfo);
+	}
+	//微信
+    public List<WorkStaffBasicInfo> wxFindAddressBook(WorkStaffBasicInfo workStaffBasicInfo){
+        String companyId = UserUtils.getUser().getComId();
+        Office office = new Office();
+        office.setId(companyId);
+        workStaffBasicInfo.setCompany(office);
+        return dao.findAddressBook(workStaffBasicInfo);
+    }
+    public Page<WorkStaffBasicInfo> findAddressBook(Page<WorkStaffBasicInfo> page, WorkStaffBasicInfo workStaffBasicInfo) {
+//        if(!UserUtils.getUser().isAdmin()) {
+//            String dataScopeSql = dataScopeFilterOR(workStaffBasicInfo.getCurrentUser(), "o", "u", "s", MenuStatusEnum.WORK_STAFFBASICINFO.getValue());
+//            workStaffBasicInfo.getSqlMap().put("dsf", dataScopeSql);
+//            if(workStaffBasicInfo.getCurrentUser().getBranchOffice()==null){
+//                workStaffBasicInfo.getCurrentUser().setBranchOffice(workStaffBasicInfo.getCurrentUser().getCompany());
+//            }
+//        }
+        String companyId = UserUtils.getUser().getComId();
+        Office office = new Office();
+        office.setId(companyId);
+        workStaffBasicInfo.setCompany(office);
+        workStaffBasicInfo.setPage(page);
+        page.setList(dao.findAddressBook(workStaffBasicInfo));
+        return page;
+    }
+
+	
+	@Transactional(readOnly = false)
+	public void save(WorkStaffBasicInfo workStaffBasicInfo,HttpServletRequest request) throws IOException {
+        String baseId = workStaffBasicInfo.getId();
+        workStaffBasicInfo.setId(workStaffBasicInfo.getAchiveId());
+        this.saveAchive(workStaffBasicInfo,request);
+        workStaffBasicInfo.setAchiveId(workStaffBasicInfo.getId());
+        workStaffBasicInfo.setId(baseId);
+		super.save(workStaffBasicInfo);
+	    //同步修改sys_user表中的name
+        if(roleService.getRoleIdByUserId(workStaffBasicInfo.getUserId())!=null){
+            //更新信息
+            User user = new User();
+            user.setId(workStaffBasicInfo.getUserId());
+            user.setName(workStaffBasicInfo.getName());
+            user.setMobile(workStaffBasicInfo.getMobile());
+            user.setPhone(workStaffBasicInfo.getPhone());
+            user.setLoginName(workStaffBasicInfo.getMobile());
+            user.setComId(workStaffBasicInfo.getCompany().getId());
+            user.setCompany(workStaffBasicInfo.getCompany());
+            user.setOffice(workStaffBasicInfo.getOffice());
+            userService.updateUser(user);
+            userService.updateRole(workStaffBasicInfo);
+        }else{
+            userService.insertRole(workStaffBasicInfo);
+        }
+	}
+
+    /**
+     * 我的信息-用户维护档案信息,
+     * @param workStaffBasicInfo
+     * @param request
+     * @throws IOException
+     */
+    @Transactional(readOnly = false)
+    public void updateAchieveDirectly(WorkStaffBasicInfo workStaffBasicInfo,HttpServletRequest request) throws IOException {
+        String staffId = workStaffBasicInfo.getId();
+        workStaffBasicInfo.setId(workStaffBasicInfo.getAchiveId());
+        this.saveAchive(workStaffBasicInfo,request);
+        workStaffBasicInfo.setAchiveId(workStaffBasicInfo.getId());
+        workStaffBasicInfo.setId(staffId);
+        super.save(workStaffBasicInfo);
+
+       //同步修改用户座机
+        User user = new User();
+        user.setId(workStaffBasicInfo.getUserId());
+        user.setPhone(workStaffBasicInfo.getPhone());
+        userService.updateUser(user);
+        UserUtils.clearCache();
+
+    }
+    public void preSave(WorkStaffBasicInfo workStaffBasicInfo, HttpServletRequest request) throws IOException {
+        if(workStaffBasicInfo.getCompany()==null){
+            workStaffBasicInfo.setCompany(UserUtils.getSelectCompany());
+        }
+        if(workStaffBasicInfo.getBranchOffice()==null|| StringUtils.isBlank(workStaffBasicInfo.getBranchOffice().getId())){
+            Office branchOffice = officeService.get(workStaffBasicInfo.getOffice().getId());
+            if(branchOffice==null||StringUtils.isBlank(branchOffice.getBranchOffice())){
+                workStaffBasicInfo.setBranchOffice(workStaffBasicInfo.getCompany());
+            }else {
+                workStaffBasicInfo.setBranchOffice(new Office(branchOffice.getBranchOffice()));
+            }
+        }
+        if(StringUtils.isBlank(workStaffBasicInfo.getNo())){
+            workStaffBasicInfo.setNo(this.createNo(workStaffBasicInfo));
+        }
+        if(StringUtils.isBlank(workStaffBasicInfo.getUserId())){
+	        //根据手机号查询用户
+            User user = userService.findUniqueByProperty("mobile", workStaffBasicInfo.getMobile());
+            if(user==null){
+                //创建新的用户
+                user = this.createUser(workStaffBasicInfo);
+                userService.save(user,request);
+            }else {
+                user = UserUtils.get(user.getId());
+                this.saveUserOffice(user,workStaffBasicInfo);
+                if(workStaffBasicInfo.getCompany().getId().equals(user.getCompany().getId())){
+                    user.setOffice(workStaffBasicInfo.getOffice());
+                    userService.updateOfficeById(user);
+                    systemService.removeSession(user);
+                    UserUtils.clearCache(user);
+                }
+            }
+            workStaffBasicInfo.setUserId(user.getId());
+        }
+    }
+
+    public void uploadFile(WorkStaffBasicInfo workStaffBasicInfo) {
+        MultipartFile pictureFile = workStaffBasicInfo.getPictureFile();
+        if (pictureFile != null && !pictureFile.isEmpty() &&pictureFile.getSize()>0) {
+            String oldPhoto = workStaffBasicInfo.getPicture();
+            BOSClientUtil bosClientUtil = new BOSClientUtil();
+            /*if (StringUtils.isNotBlank(oldPhoto)) {
+                String aliyunUrl = Global.getAliyunUrl();
+                String aliDownloadUrl = Global.getAliDownloadUrl();
+                String cons = "";
+                if (oldPhoto.contains(aliyunUrl)) {
+                    cons = aliyunUrl;
+                } else if (oldPhoto.contains("http://gangwan-app.oss-cn-hangzhou.aliyuncs.com")) {
+                    cons = "http://gangwan-app.oss-cn-hangzhou.aliyuncs.com";
+                } else {
+                    cons = aliDownloadUrl;
+                }
+                String[] arr = oldPhoto.split(cons + "/");
+                key = arr[1];
+            }
+            try {
+                OSSClientUtil ossUtil1 = new OSSClientUtil();
+                if (StringUtils.isNotBlank(key)) {
+                    ossUtil1.deleteSingleObject(key);
+                }
+            }catch (Exception e){
+                logger.error("oss删除文件失败!");
+            }*/
+            try {
+                if(StringUtils.isNotBlank(oldPhoto)){
+                    bosClientUtil.deleteObject(oldPhoto);
+                }
+                String path = new StringBuilder("/headImg/")
+                        .append(workStaffBasicInfo.getName()+System.currentTimeMillis()).append(".png").toString();
+                String uploadPath = bosClientUtil.upload(path, pictureFile.getInputStream());
+                workStaffBasicInfo.setPicture(uploadPath);
+            } catch (Exception e) {
+                logger.error("oss上传文件失败!");
+            }
+        }
+    }
+
+    public Page<WorkStaffBasicInfo> getByRoleId(Page<WorkStaffBasicInfo> page, WorkStaffBasicInfo workStaffBasicInfo, String roleId){
+	    if (workStaffBasicInfo==null){
+            workStaffBasicInfo = new WorkStaffBasicInfo();
+        }
+        workStaffBasicInfo.setRoleId(roleId);
+        workStaffBasicInfo.setPage(page);
+        List<WorkStaffBasicInfo> list = workStaffAchivesDao.findListByRoleList(workStaffBasicInfo);
+        page.setList(list);
+        return page;
+    }
+
+    private String cacuPercent(int cou) {
+        BigDecimal bigDecimal = new BigDecimal(cou).divide(new BigDecimal("39"),2,BigDecimal.ROUND_HALF_UP);
+        NumberFormat percent = NumberFormat.getPercentInstance();
+        return percent.format(bigDecimal.doubleValue());
+    }
+
+    private void saveUserOffice(User user,WorkStaffBasicInfo workStaffBasicInfo) {
+        Useroffice useroffice = new Useroffice();
+        useroffice.setUserId(user.getId());
+        useroffice.setStatus("3");
+        useroffice.setMaster(UserUtils.getUser().getId());
+        useroffice.setCompanyId(workStaffBasicInfo.getCompany().getId());
+        useroffice.setOfficeId(workStaffBasicInfo.getOffice().getId());
+        List<Useroffice> listOffice = userofficeService.findList(useroffice);
+        if(listOffice==null || listOffice.size()==0){
+            userofficeService.save(useroffice);
+        }else {
+            Useroffice oldUseroffice = listOffice.get(0);
+            oldUseroffice.setOfficeId(workStaffBasicInfo.getOffice().getId());
+            userofficeService.save(oldUseroffice);
+        }
+    }
+
+    private void saveAchive(WorkStaffBasicInfo workStaffBasicInfo) {
+        if (workStaffBasicInfo.getIsNewRecord()){
+            workStaffBasicInfo.preInsert();
+            workStaffAchivesDao.insert(workStaffBasicInfo);
+        }else{
+            workStaffBasicInfo.preUpdate();
+            workStaffAchivesDao.update(workStaffBasicInfo);
+        }
+    }
+
+    private int cacuField(WorkStaffBasicInfo workStaffBasicInfo) {
+        int count = 0;
+        Class<? extends WorkStaffBasicInfo> basicInfoClass = workStaffBasicInfo.getClass();
+        Field[] declaredFields = basicInfoClass.getDeclaredFields();
+        for (Field field : declaredFields) {
+            String name = field.getName();
+            if("userId".equals(name)||"sqlStr".equals(name)||"branchOffice".equals(name)||"company".equals(name)||"dimissionDate".equals(name)
+                    || "percent".equals(name)||"freeEndDate".equals(name)||"workEndDate".equals(name)||"pictureFile".equals(name)||"achiveId".equals(name)
+                    ||"relationshipStatus".equals(name)||"labourList".equals(name)||"notifyFlag".equals(name)||"serialVersionUID".equals(name)||"tryEndTime".equals(name)){
+                continue;
+            }
+            String methodName = "get"+name.substring(0,1).toUpperCase()+name.substring(1);
+            try {
+                Object invoke = basicInfoClass.getMethod(methodName).invoke(workStaffBasicInfo);
+                if(invoke==null)continue;
+                if(invoke instanceof List)continue;
+                if(invoke instanceof String && StringUtils.isBlank((String) invoke)){
+                    continue;
+                }
+                if (invoke instanceof Area && StringUtils.isBlank(((Area) invoke).getId())){
+                    continue;
+                }
+                count++;
+            } catch (NoSuchMethodException e) {
+                e.printStackTrace();
+            } catch (IllegalAccessException e) {
+                e.printStackTrace();
+            } catch (InvocationTargetException e) {
+                e.printStackTrace();
+            }
+        }
+        return count;
+    }
+
+    private void sendMessage(WorkStaffBasicInfo workStaffBasicInfo, String contentStr, String titleStr, String remark) {
+	    if (workStaffBasicInfo==null||StringUtils.isBlank(workStaffBasicInfo.getId())||StringUtils.isBlank(workStaffBasicInfo.getUserId())){
+	        return;
+        }
+        WorkProjectNotify workProjectNotify = UtilNotify.saveNotify(workStaffBasicInfo.getId(),null, workStaffBasicInfo.getCompany().getId(),
+                titleStr, contentStr,"69","0",remark,"");
+        List<String> userIds = new ArrayList<>();
+        userIds.add(workStaffBasicInfo.getUserId());
+        workProjectNotify.setUser(new User(workStaffBasicInfo.getUserId()));
+        workProjectNotify.setId("");
+        workProjectNotify.setNotifyRole("");
+        workProjectNotifyService .save(workProjectNotify);
+        UserUtils.pushIm(userIds,contentStr);
+    }
+
+    private String createNo(WorkStaffBasicInfo workStaffBasicInfo) {
+        String newNo="0001";
+        String no = dao.queryMaxNoWithCompany(workStaffBasicInfo);
+        if(StringUtils.isNotBlank(no)){
+            Integer integer = Integer.valueOf(no);
+            integer+=1;
+            newNo = String.valueOf(integer);
+        }
+        no = UserUtils.getSysParam("company_number",UserUtils.getUser());
+        if(StringUtils.isBlank(no)){
+            no = "0000";
+        }
+        for(int i = newNo.length(); i<4; i++){
+            newNo = "0"+newNo;
+        }
+        return no+newNo;
+    }
+
+    private User createUser(WorkStaffBasicInfo workStaffBasicInfo) {
+        User user = new User();
+        user.setOffice(workStaffBasicInfo.getOffice());
+        user.setCompany(workStaffBasicInfo.getCompany());
+        user.setComId(workStaffBasicInfo.getCompany().getId());
+        user.setNo(workStaffBasicInfo.getNo());
+        user.setName(workStaffBasicInfo.getName());
+        user.setMobile(workStaffBasicInfo.getMobile());
+        user.setNewPassword("123456");
+        user.setLoginName(workStaffBasicInfo.getMobile());
+        user.setEmail(workStaffBasicInfo.getEmail());
+        user.setSex(workStaffBasicInfo.getGender());
+        user.setLoginFlag("1");
+        user.setFirstFlag("1");
+        //微信标识
+        user.setWeChatId(workStaffBasicInfo.getNo());
+        return user;
+    }
+
+    private int saveDetails(WorkStaffBasicInfo workStaffBasicInfo,boolean first) {
+	    int count = 0;
+	    if(achievementService.save(workStaffBasicInfo,first))count++;
+	    if(certificateService.save(workStaffBasicInfo,first))count++;
+	    if(educationService.save(workStaffBasicInfo,first))count++;
+	    if(experienceService.save(workStaffBasicInfo,first))count++;
+	    if(familyService.save(workStaffBasicInfo,first))count++;
+	    if(languagesService.save(workStaffBasicInfo,first))count++;
+	    if(recordService.save(workStaffBasicInfo,first))count++;
+	    if(rewardsService.save(workStaffBasicInfo,first))count++;
+	    if(socialPositionService.save(workStaffBasicInfo,first))count++;
+	    if(titleService.save(workStaffBasicInfo,first))count++;
+	    if(trainingService.save(workStaffBasicInfo,first))count++;
+	    return count;
+    }
+
+    public void queryDetails(WorkStaffBasicInfo workStaffBasicInfo){
+        //按照achieveId查询
+        String id = workStaffBasicInfo.getId();
+        if (StringUtils.isNotBlank(id) && StringUtils.isNotBlank(workStaffBasicInfo.getAchiveId())){
+            workStaffBasicInfo.setId(workStaffBasicInfo.getAchiveId());
+        }
+        achievementService.query(workStaffBasicInfo);
+        certificateService.query(workStaffBasicInfo);
+        educationService.query(workStaffBasicInfo);
+        experienceService.query(workStaffBasicInfo);
+        familyService.query(workStaffBasicInfo);
+        languagesService.query(workStaffBasicInfo);
+        recordService.query(workStaffBasicInfo);
+        rewardsService.query(workStaffBasicInfo);
+        socialPositionService.query(workStaffBasicInfo);
+        titleService.query(workStaffBasicInfo);
+        trainingService.query(workStaffBasicInfo);
+        queryRelationShips(workStaffBasicInfo);
+        workStaffBasicInfo.setId(id);
+    }
+
+    public void queryRelationShips(WorkStaffBasicInfo workStaffBasicInfo) {
+        List<WorkRelationship> workRelationships = workRelationshipDao.getWorkRelationships(null, workStaffBasicInfo.getId());
+        workStaffBasicInfo.setLabourList(workRelationships);
+        if(workRelationships!=null&&workRelationships.size()>0){
+            for (WorkRelationship workRelationship : workRelationships) {
+                if(workRelationship!=null && workRelationship.getWorkStaffBasicInfo()!=null && StringUtils.isNotBlank(workRelationship.getWorkStaffBasicInfo().getId())) {
+                    WorkClientAttachment workClientAttachment = new WorkClientAttachment();
+                    workClientAttachment.setAttachmentId(workRelationship.getId());
+                    workClientAttachment.setAttachmentFlag("108");
+                    workRelationship.setWorkAttachments(workClientAttachmentDao.findList(workClientAttachment));
+                }
+            }
+        }
+    }
+
+    @Transactional(readOnly = false)
+	public void delete(WorkStaffBasicInfo workStaffBasicInfo) {
+//		super.delete(workStaffBasicInfo);
+        workStaffBasicInfoDao.deleteByLogic(workStaffBasicInfo);
+	}
+
+	public WorkStaffBasicInfo findNo(String no){
+       return workStaffBasicInfoDao.getNo(no);
+    }
+
+    public WorkStaffBasicInfo findByIdCardAndCom(String idCard) {
+	    WorkStaffBasicInfo select = new WorkStaffBasicInfo();
+	    select.setIdCard(idCard);
+	    select.setCompany(UserUtils.getSelectCompany());
+        List<WorkStaffBasicInfo> list = workStaffAchivesDao.findListByIdCard(select);
+        if(list==null||list.size()<=0){
+            return null;
+        }
+        //判断是否存在在职
+        for (WorkStaffBasicInfo workStaffBasicInfo : list) {
+            if(!("离职".equals(workStaffBasicInfo.getStatus())||"退休".equals(workStaffBasicInfo.getStatus()))){
+                return workStaffBasicInfo;
+            }
+        }
+        WorkStaffBasicInfo workStaffBasicInfo = list.get(0);
+        return workStaffBasicInfo;
+    }
+    public  Page<WorkStaffBasicInfo> findUserListPage(Page<WorkStaffBasicInfo> page, WorkStaffBasicInfo workStaffBasicInfo) {
+        workStaffBasicInfo.setPage(page);
+        page.setList(workStaffAchivesDao.findUserList(workStaffBasicInfo));
+        return page;
+    }
+    public  Page<WorkStaffBasicInfo> findUserApplyPage(Page<WorkStaffBasicInfo> page, WorkStaffBasicInfo workStaffBasicInfo) {
+        workStaffBasicInfo.setPage(page);
+        page.setList(workStaffAchivesDao.findUserApplyList(workStaffBasicInfo));
+        return page;
+    }
+    public  Page<WorkStaffBasicInfo> findUserShipList(Page<WorkStaffBasicInfo> page, WorkStaffBasicInfo workStaffBasicInfo) {
+        workStaffBasicInfo.setPage(page);
+        page.setList(workStaffAchivesDao.findUserShipList(workStaffBasicInfo));
+        return page;
+    }
+    public  Page<WorkStaffBasicInfo> findTemplateUser(Page<WorkStaffBasicInfo> page, WorkStaffBasicInfo workStaffBasicInfo) {
+        workStaffBasicInfo.setPage(page);
+        page.setList(workStaffAchivesDao.findTemplateUser(workStaffBasicInfo));
+        return page;
+    }
+    public WorkStaffBasicInfo queryAchive(WorkStaffBasicInfo workStaffBasicInfo) {
+        WorkStaffBasicInfo staffBasicInfo = workStaffAchivesDao.get(workStaffBasicInfo.getAchiveId());
+        staffBasicInfo.setNo(null);
+        staffBasicInfo.setAchiveId(null);
+        //设置工号
+        Office branchOffice = officeService.get(workStaffBasicInfo.getOffice().getId());
+        if(branchOffice==null||StringUtils.isBlank(branchOffice.getBranchOffice())){
+            branchOffice=workStaffBasicInfo.getCompany();
+        }
+        workStaffBasicInfo.setBranchOffice(new Office(branchOffice.getBranchOffice()));
+        //userId
+        List<WorkStaffBasicInfo> list = dao.findListByUserId(workStaffBasicInfo);
+        if(list!=null&&list.size()>0){
+            WorkStaffBasicInfo basicInfo = list.get(0);
+            staffBasicInfo.setNo(basicInfo.getNo());
+            //设置当前分公司档案信息
+            staffBasicInfo.setAchiveId(basicInfo.getAchiveId());
+        }
+        return staffBasicInfo;
+    }
+
+    public Page<WorkStaffBasicInfo> findAchivePage(Page<WorkStaffBasicInfo> page, WorkStaffBasicInfo workStaffBasicInfo) {
+        if(!UserUtils.getUser().isAdmin()) {
+            String dataScopeSql = dataScopeFilterOR(workStaffBasicInfo.getCurrentUser(), "o", "u", "s", MenuStatusEnum.WORK_STAFFBASICINFO.getValue());
+            workStaffBasicInfo.getSqlMap().put("dsf", dataScopeSql);
+            if(workStaffBasicInfo.getCurrentUser().getBranchOffice()==null){
+                workStaffBasicInfo.getCurrentUser().setBranchOffice(workStaffBasicInfo.getCurrentUser().getCompany());
+            }
+            workStaffBasicInfo.setPage(page);
+            page.setList(workStaffAchivesDao.findList(workStaffBasicInfo));
+        }else {
+            page.setList(new ArrayList<WorkStaffBasicInfo>());
+        }
+
+        return page;
+    }
+
+    public WorkStaffBasicInfo getByAchiveId(WorkStaffBasicInfo workStaffBasicInfo) {
+        Office branchOffice = officeService.get(workStaffBasicInfo.getOffice().getId());
+        if(branchOffice==null||StringUtils.isBlank(branchOffice.getBranchOffice())){
+            branchOffice=workStaffBasicInfo.getCompany();
+        }
+        workStaffBasicInfo.setBranchOffice(new Office(branchOffice.getBranchOffice()));
+        List<WorkStaffBasicInfo> list = this.findList(workStaffBasicInfo);
+        if (list==null||list.size()<=0){
+            return workStaffBasicInfo;
+        }
+        return list.get(0);
+    }
+
+    @Transactional(readOnly = false)
+    public void complete(String achiveIds) {
+        if(StringUtils.isBlank(achiveIds)){
+            return;
+        }
+        String[] split = achiveIds.split(",");
+        String contentStr = "待处理,请及时完善员工档案信息。";
+        String titleStr = "完善档案信息,待处理";
+        String remark = "待处理";
+        for (String s : split) {
+            WorkStaffBasicInfo workStaffBasicInfo = workStaffAchivesDao.get(s);
+            this.sendMessage(workStaffBasicInfo,contentStr,titleStr,remark);
+        }
+    }
+
+    @Transactional(readOnly = false)
+    public void saveAchive(WorkStaffBasicInfo workStaffBasicInfo, HttpServletRequest request) throws IOException {
+        Office branchOffice = officeService.get(workStaffBasicInfo.getOffice().getId());
+        if(branchOffice!=null&&StringUtils.isNotBlank(branchOffice.getBranchOffice())){
+            workStaffBasicInfo.setBranchOffice(new Office(branchOffice.getBranchOffice()));
+        }
+        this.preSave(workStaffBasicInfo, request);
+//        this.uploadFile(workStaffBasicInfo);
+        this.saveAchive(workStaffBasicInfo);
+        workStaffBasicInfo.setAchiveId(workStaffBasicInfo.getId());
+        int cou = this.saveDetails(workStaffBasicInfo,true);
+        //计算信息完成度
+        cou +=this.cacuField(workStaffBasicInfo);
+        workStaffAchivesDao.updatePercent(workStaffBasicInfo.getId(),this.cacuPercent(cou));
+        if (StringUtils.isNotBlank(workStaffBasicInfo.getHome()) && "home".equals(workStaffBasicInfo.getHome())){
+            WorkProjectNotify workProjectNotify = new WorkProjectNotify();
+            workProjectNotify.setNotifyId(workStaffBasicInfo.getId());
+            workProjectNotifyService.readByNotifyId(workProjectNotify);
+            return;
+        }
+        if("1".equals(workStaffBasicInfo.getNotifyFlag())){
+            String contentStr = "待处理,请及时完善员工档案信息。";
+            String titleStr = "完善档案信息,待处理";
+            String remark = "待处理";
+            this.sendMessage(workStaffBasicInfo,contentStr,titleStr,remark);
+        }
+    }
+
+    public WorkStaffBasicInfo getAchive(WorkStaffBasicInfo workStaffBasicInfo) {
+	    workStaffBasicInfo.setId(workStaffBasicInfo.getAchiveId());
+        return workStaffAchivesDao.get(workStaffBasicInfo.getId());
+    }
+
+    public boolean validateStaff(WorkStaffBasicInfo workStaffBasicInfo,StringBuilder errInfo) {
+	    boolean flag = true;
+	    if(workStaffBasicInfo==null){
+	        return false;
+        }
+	    if(workStaffBasicInfo.getCompany()==null){
+	        workStaffBasicInfo.setCompany(UserUtils.getSelectCompany());
+        }
+        if(StringUtils.isBlank(workStaffBasicInfo.getName())){
+            errInfo.append("员工姓名不能为空");
+            flag = false;
+        }
+        if(workStaffBasicInfo.getOffice()==null||StringUtils.isBlank(workStaffBasicInfo.getOffice().getId())){
+	        errInfo.append("所属部门不能为空");
+            flag = false;
+        }
+        if(StringUtils.isBlank(workStaffBasicInfo.getIdCard())){
+            errInfo.append("身份证号不能为空");
+            flag = false;
+        }
+        if(StringUtils.isBlank(workStaffBasicInfo.getMobile())){
+	        errInfo.append("手机号不能为空");
+	        flag = false;
+        }
+	    if(StringUtils.isNotBlank(workStaffBasicInfo.getNo())) {
+           int cou = workStaffAchivesDao.countByNo(workStaffBasicInfo);
+           if(cou>0){
+               errInfo.append("重复的工号");
+               flag = false;
+           }
+        }
+
+        if(StringUtils.isNotBlank(workStaffBasicInfo.getIdCard())){
+            WorkStaffBasicInfo staffBasicInfo = this.findByIdCardAndCom(workStaffBasicInfo.getIdCard());
+            if(staffBasicInfo!=null&&StringUtils.isNotBlank(staffBasicInfo.getId())){
+                if(!("离职".equals(staffBasicInfo.getStatus())||"退休".equals(staffBasicInfo.getStatus()))){
+                    errInfo.append("重复的身份证号");
+                    flag = false;
+                }
+            }
+        }
+        return flag;
+    }
+    public void queryDetailsApply(WorkStaffBasicInfo workStaffBasicInfo){
+        achievementService.querys(workStaffBasicInfo);
+        certificateService.querys(workStaffBasicInfo);
+        educationService.querys(workStaffBasicInfo);
+        experienceService.querys(workStaffBasicInfo);
+        familyService.querys(workStaffBasicInfo);
+        languagesService.querys(workStaffBasicInfo);
+        recordService.querys(workStaffBasicInfo);
+        rewardsService.querys(workStaffBasicInfo);
+        socialPositionService.querys(workStaffBasicInfo);
+        titleService.querys(workStaffBasicInfo);
+        trainingService.querys(workStaffBasicInfo);
+        queryRelationShips(workStaffBasicInfo);
+    }
+    private int saveDetailsApply(WorkStaffBasicInfo workStaffBasicInfo,boolean first) {
+        int count = 0;
+        if(achievementService.saveApply(workStaffBasicInfo,first))count++;
+        if(certificateService.saveApply(workStaffBasicInfo,first))count++;
+        if(educationService.saveApply(workStaffBasicInfo,first))count++;
+        if(experienceService.saveApply(workStaffBasicInfo,first))count++;
+        if(familyService.saveApply(workStaffBasicInfo,first))count++;
+        if(languagesService.saveApply(workStaffBasicInfo,first))count++;
+        if(recordService.saveApply(workStaffBasicInfo,first))count++;
+        if(rewardsService.saveApply(workStaffBasicInfo,first))count++;
+        if(socialPositionService.saveApply(workStaffBasicInfo,first))count++;
+        if(titleService.saveApply(workStaffBasicInfo,first))count++;
+        if(trainingService.saveApply(workStaffBasicInfo,first))count++;
+        return count;
+    }
+    @Transactional(readOnly = false)
+    public String completeApply(String achiveIds) {
+        if(StringUtils.isBlank(achiveIds)){
+            return"";
+        }
+        String contentStr = "待处理,请及时审核修改档案信息申请。";
+        String titleStr = "修改档案信息申请,待处理";
+        String remark = "待处理";
+        WorkStaffBasicInfo workStaffBasicInfo = workStaffAchivesDao.get(achiveIds);
+        WorkProjectNotify workProjectNotify = UtilNotify.saveNotify(workStaffBasicInfo.getId(),null, workStaffBasicInfo.getCompany().getId(),
+                titleStr, contentStr,"86","0",remark,"");
+        List<String> userIds = new ArrayList<>();
+        List<User> rlzyList = UserUtils.getByRoleActivityEnname("rlzy",3,UserUtils.getSelectOffice().getId(),"22",UserUtils.getUser());
+        List<User> rszrList = UserUtils.findRszrList(UserUtils.getUser());
+        rlzyList.addAll(rszrList);
+        if (rlzyList.size()==0 ){
+            return "流程审批人不能为空,请联系管理员!";
+        }
+        for(User u:rlzyList){
+            userIds.add(u.getId());
+            workProjectNotify.setUser(u);
+            workProjectNotify.setId("");
+            workProjectNotify.setNotifyRole("");
+            workProjectNotifyService .save(workProjectNotify);
+        }
+        UserUtils.pushIm(userIds,contentStr);
+        return"";
+    }
+    @Transactional(readOnly = false)
+    public void saveAchiveApply(WorkStaffBasicInfo workStaffBasicInfo, HttpServletRequest request) throws IOException {
+        this.saveAchive(workStaffBasicInfo);
+        workStaffBasicInfo.setAchiveId(workStaffBasicInfo.getId());
+        int cou = this.saveDetailsApply(workStaffBasicInfo,true);
+        //计算信息完成度
+        cou +=this.cacuField(workStaffBasicInfo);
+        workStaffAchivesDao.updatePercent(workStaffBasicInfo.getId(),this.cacuPercent(cou));
+        workStaffAchivesLogDao.updateState(workStaffBasicInfo.getId(),UserUtils.getUser().getId(),new Date());
+        if (StringUtils.isNotBlank(workStaffBasicInfo.getHome()) && "home".equals(workStaffBasicInfo.getHome())){
+            WorkProjectNotify workProjectNotify = new WorkProjectNotify();
+            workProjectNotify.setNotifyId(workStaffBasicInfo.getId());
+            workProjectNotifyService.readByNotifyId(workProjectNotify);
+            return;
+        }
+        if("1".equals(workStaffBasicInfo.getNotifyFlag())){
+            String contentStr = "待处理,请及时完善员工档案信息。";
+            String titleStr = "完善档案信息,待处理";
+            String remark = "待处理";
+            this.sendMessage(workStaffBasicInfo,contentStr,titleStr,remark);
+        }
+    }
+    private static Map<String,String> CODE_MAP = Maps.newHashMap();//基本信息
+    static{//基本信息
+        CODE_MAP.put("exSoldier", "是否退伍军人");
+        CODE_MAP.put("marriage", "婚姻状况");
+        CODE_MAP.put("politics", "政治面貌");
+        CODE_MAP.put("address", "常住地址");
+        CODE_MAP.put("household", "户口所在地");
+        CODE_MAP.put("nativePlace", "籍贯");
+        CODE_MAP.put("picture", "头像");
+        CODE_MAP.put("industryDate", "从事本行业日期");
+    }
+    @Transactional(readOnly = false)
+    public void saveLog(WorkStaffBasicInfo workStaffBasicInfo) {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
+        WorkStaffBasicInfo select1 = new WorkStaffBasicInfo();
+        select1.setAchiveId(workStaffBasicInfo.getId());
+        WorkStaffBasicInfo w = this.getAchive(select1);//从数据库取出记录的值
+        Class<? extends WorkStaffBasicInfo> basicInfoClass = workStaffBasicInfo.getClass();
+        Class<? extends WorkStaffBasicInfo> wClass = w.getClass();
+        Field[] declaredFields = basicInfoClass.getDeclaredFields();
+        if(workStaffBasicInfo.getPictureFile()!=null&&!workStaffBasicInfo.getPictureFile().isEmpty()&&workStaffBasicInfo.getPictureFile().getSize()>0){
+            MultipartFile file = workStaffBasicInfo.getPictureFile();
+            this.uploadFile(workStaffBasicInfo);
+        }
+        for (Field field : declaredFields) {
+            String name = field.getName();
+            if("picture".equals(name)||"marriage".equals(name)||"politics".equals(name)||"exSoldier".equals(name)||"address".equals(name)
+                    || "nativePlace".equals(name)||"household".equals(name)||"industryDate".equals(name)){
+                String methodName = "get"+name.substring(0,1).toUpperCase()+name.substring(1);
+                WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+                workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+                workStaffAchivesLog.setModule("基本信息");
+                workStaffAchivesLog.setFields(name);
+                workStaffAchivesLog.setState("1");
+                try {
+                    Object newInvoke = basicInfoClass.getMethod(methodName).invoke(workStaffBasicInfo);//修改后
+                    Object oldInvoke = wClass.getMethod(methodName).invoke(w);//修改前
+                    String describes=CODE_MAP.get(name);
+                    if(newInvoke==null)continue;
+                    if(newInvoke instanceof String){
+                        String newValue=newInvoke.toString();
+                        String oldValue = "";
+                        if (oldInvoke!=null)
+                            oldValue = oldInvoke.toString();
+                        if(!newValue.equals(oldValue)){
+                            if("exSoldier".equals(name)){
+                                workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                        "基本信息",describes,name,
+                                        DictUtils.getDictLabel(oldValue,"yes_no",""),
+                                        DictUtils.getDictLabel(newValue,"yes_no",""),
+                                        oldValue,
+                                        newValue,
+                                        "","修改");
+                            }else{
+                                workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                        "基本信息",describes,name,
+                                        oldValue,newValue,oldValue,newValue,"","修改");
+                            }
+
+                        }
+                    }
+                    if(newInvoke instanceof Date){//日期
+                        String newDate="";
+                        String oldDate="";
+                        if(newInvoke!=null){
+                            newDate=sdf.format(newInvoke);
+                        }
+                        if(oldInvoke!=null){
+                           oldDate=sdf.format(oldInvoke);
+                        }
+                            if(!newDate.equals(oldDate)){
+                                workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                        "基本信息",describes,name,
+                                        oldDate,newDate,oldDate,newDate,"","修改");
+                            }
+                    };
+                    if (newInvoke instanceof Area){
+                        String id=((Area) newInvoke).getId();
+                        Area a=areaDao.get(id);
+                        if(!((Area) newInvoke).getId().equals(((Area) oldInvoke).getId())){
+                            workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                    "基本信息",describes,name,
+                                    ((Area) oldInvoke).getName(),a.getName(),
+                                    ((Area) oldInvoke).getId(),id,"","修改");
+                        }
+                    }
+                } catch (NoSuchMethodException e) {
+                    e.printStackTrace();
+                } catch (IllegalAccessException e) {
+                    e.printStackTrace();
+                } catch (InvocationTargetException e) {
+                    e.printStackTrace();
+                }
+            }
+
+        }
+        educationService.saveEdu(workStaffBasicInfo);//教育经历
+        languagesService.saveEdu(workStaffBasicInfo);//外语语种
+        experienceService.saveEdu(workStaffBasicInfo);//工作经历
+        achievementService.saveEdu(workStaffBasicInfo);//工作业绩
+        certificateService.saveEdu(workStaffBasicInfo);//执业资格证书
+        familyService.saveEdu(workStaffBasicInfo);//家庭情况
+        recordService.saveEdu(workStaffBasicInfo);//电子档案
+        rewardsService.saveEdu(workStaffBasicInfo);//奖惩情况
+        socialPositionService.saveEdu(workStaffBasicInfo);//社会及行业职务
+        titleService.saveEdu(workStaffBasicInfo);//职称
+        trainingService.saveEdu(workStaffBasicInfo);//培训经历
+    }
+
+    /**
+     * 修改员工状态
+     */
+    @Transactional(readOnly = false)
+    public void updateStatus(String id){
+        String status = "正式";
+        workStaffBasicInfoDao.updateStatus(id,status);
+        workStaffAchivesDao.updateStatus(id,status);
+
+    }
+
+    /**
+     * 同步修改work_staff_basic_info和work_staff_achives
+     * @param workStaffBasicInfo
+     */
+    @Transactional(readOnly = false)
+    public void updateWorkStaffBasicInfo(WorkStaffBasicInfo workStaffBasicInfo){
+        workStaffBasicInfoDao.updateWorkStaffBasicInfo(workStaffBasicInfo);
+        workStaffAchivesDao.updateWorkStaffAchieves(workStaffBasicInfo);
+    }
+
+    public WorkStaffBasicInfo getBasicInfoByAchiveId(String achiveId){
+        return workStaffBasicInfoDao.getByAchieveId(achiveId);
+    }
+
+
+
+}

+ 483 - 0
src/main/java/com/jeeplus/modules/workstaff/service/WorkStaffCertificateService.java

@@ -0,0 +1,483 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workstaff.service;
+
+import java.io.InputStream;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.jeeplus.common.bos.BOSClientUtil;
+import com.jeeplus.common.config.Global;
+import com.jeeplus.common.oss.OSSClientUtil;
+import com.jeeplus.common.utils.DateUtils;
+import com.jeeplus.common.utils.IdGen;
+import com.jeeplus.common.utils.StringUtils;
+import com.jeeplus.modules.sys.dao.UserDao;
+import com.jeeplus.modules.sys.entity.User;
+import com.jeeplus.modules.sys.utils.DictUtils;
+import com.jeeplus.modules.workstaff.entity.WorkStaffBasicInfo;
+import com.jeeplus.modules.workstaff.entity.WorkStaffEducation;
+import com.jeeplus.modules.workstaffachiveslog.entity.WorkStaffAchivesLog;
+import com.jeeplus.modules.workstaffachiveslog.service.WorkStaffAchivesLogService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.jeeplus.common.persistence.Page;
+import com.jeeplus.common.service.CrudService;
+import com.jeeplus.modules.workstaff.entity.WorkStaffCertificate;
+import com.jeeplus.modules.workstaff.dao.WorkStaffCertificateDao;
+import org.springframework.web.multipart.MultipartFile;
+
+/**
+ * 执业资格证书Service
+ * @author ssrh
+ * @version 2018-07-27
+ */
+@Service
+@Transactional(readOnly = true)
+public class WorkStaffCertificateService extends CrudService<WorkStaffCertificateDao, WorkStaffCertificate> {
+    @Autowired
+    private WorkStaffAchivesLogService workStaffAchivesLogService;
+    @Autowired
+    private UserDao userDao;
+	public WorkStaffCertificate get(String id) {
+		return super.get(id);
+	}
+	
+	public List<WorkStaffCertificate> findList(WorkStaffCertificate workStaffCertificate) {
+		return super.findList(workStaffCertificate);
+	}
+	
+	public Page<WorkStaffCertificate> findPage(Page<WorkStaffCertificate> page, WorkStaffCertificate workStaffCertificate) {
+		return super.findPage(page, workStaffCertificate);
+	}
+	
+	@Transactional(readOnly = false)
+	public void save(WorkStaffCertificate workStaffCertificate) {
+		super.save(workStaffCertificate);
+	}
+	
+	@Transactional(readOnly = false)
+	public void delete(WorkStaffCertificate workStaffCertificate) {
+		super.delete(workStaffCertificate);
+	}
+
+
+    public boolean save(WorkStaffBasicInfo workStaffBasicInfo,boolean first) {
+        if(workStaffBasicInfo==null|| StringUtils.isBlank(workStaffBasicInfo.getId())){
+            return false;
+        }
+        if(workStaffBasicInfo.getCertificateList()==null||workStaffBasicInfo.getCertificateList().size()<=0){
+            return false;
+        }
+        boolean flag=false;
+        for (WorkStaffCertificate entity : workStaffBasicInfo.getCertificateList()) {
+            if(entity!=null&&"1".equals(entity.getDelFlag())&&StringUtils.isBlank(entity.getId())){
+                continue;
+            }
+            if(entity!=null&&"1".equals(entity.getDelFlag())){
+                dao.deleteByLogic(entity);
+                continue;
+            }
+            if(entity!=null){
+                if(entity.getFile()!=null&&!entity.getFile().isEmpty()&&entity.getFile().getSize()>0){
+                    MultipartFile file = entity.getFile();
+                    entity.setFileName(file.getOriginalFilename());
+                    entity.setFilePath(this.uploadFile(file,entity.getFilePath()));
+                }
+                entity.setStaffId(workStaffBasicInfo.getId());
+                this.save(entity);
+                if(first){
+                    entity.setId(null);
+                    entity.setFilePath("");
+                }
+                flag =true;
+            }
+        }
+        return flag;
+    }
+
+    /*public String uploadFile(MultipartFile file, String filePath) {
+        if (file != null && !file.isEmpty() &&file.getSize()>0) {
+            String key = "";
+            if (StringUtils.isNotBlank(filePath)) {
+                String aliyunUrl = Global.getAliyunUrl();
+                String aliDownloadUrl = Global.getAliDownloadUrl();
+                String cons = "";
+                if (filePath.contains(aliyunUrl)) {
+                    cons = aliyunUrl;
+                } else if (filePath.contains("http://gangwan-app.oss-cn-hangzhou.aliyuncs.com")) {
+                    cons = "http://gangwan-app.oss-cn-hangzhou.aliyuncs.com";
+                } else {
+                    cons = aliDownloadUrl;
+                }
+                String[] arr = filePath.split(cons + "/");
+                key = arr[1];
+            }
+            try {
+                OSSClientUtil ossUtil1 = new OSSClientUtil();
+                if (StringUtils.isNotBlank(key)) {
+                    ossUtil1.deleteSingleObject(key);
+                }
+            }catch (Exception e){
+                logger.error("oss删除文件失败!");
+            }
+            try {
+                OSSClientUtil ossUtil = new OSSClientUtil();
+                String path = Global.getStaffBasicFilePath()+ DateUtils.formatDate(new Date(),null)+"/";
+                String newName = System.currentTimeMillis()+"-"+file.getOriginalFilename();
+                ossUtil.uploadFile2OSS(file.getInputStream(),path,newName);
+                return  Global.getAliDownloadUrl() + "/" + path + newName;
+            } catch (Exception e) {
+                logger.error("oss上传文件失败!");
+            }
+        }
+        return filePath;
+    }*/
+    public String uploadFile(MultipartFile file, String filePath){
+        String date = DateUtils.formatDate(new Date(),"yyMMddHHmm");
+        try {
+            if (file != null && file.getSize() > 0) {
+                String path = new StringBuilder("/employeeInfo/").append(date)
+                        .append(file.getOriginalFilename()).toString();
+                InputStream inputStream = file.getInputStream();
+                BOSClientUtil bosClientUtil = new BOSClientUtil();
+                String url = bosClientUtil.upload(path, inputStream);
+                return url;
+            }
+        }catch (Exception e){
+            logger.error("上传文件失败!");
+        }
+        return null;
+    }
+
+    public void query(WorkStaffBasicInfo workStaffBasicInfo) {
+        if(workStaffBasicInfo==null|| StringUtils.isBlank(workStaffBasicInfo.getId())){
+            return;
+        }
+        WorkStaffCertificate entity = new WorkStaffCertificate();
+        entity.setStaffId(workStaffBasicInfo.getId());
+        workStaffBasicInfo.setCertificateList(this.findList(entity));
+    }
+    private static Map<String,String> EDU_MAP = Maps.newHashMap();//教育经历
+
+    static{//教育经历
+        EDU_MAP.put("name", "证书名称");
+        EDU_MAP.put("num", "证书编号");
+        EDU_MAP.put("issuingAuthority", "发证机关");
+        EDU_MAP.put("issuingDate", "发证日期");
+        EDU_MAP.put("registDate", "注册日期");
+        EDU_MAP.put("registNum", "注册证书编号");
+        EDU_MAP.put("major", "专业");
+        EDU_MAP.put("grade", "等级");
+        EDU_MAP.put("issType", "取得方式");
+        EDU_MAP.put("filePath", "文件");
+        EDU_MAP.put("fileName", "文件名");
+    }
+    public boolean saveApply(WorkStaffBasicInfo workStaffBasicInfo,boolean first) {
+        if(workStaffBasicInfo==null|| StringUtils.isBlank(workStaffBasicInfo.getId())){
+            return false;
+        }
+        List<WorkStaffCertificate> list = workStaffBasicInfo.getCertificateList();
+        if(list==null||list.size()<=0){
+            return false;
+        }
+        boolean flag = false;
+        User u=userDao.get(workStaffBasicInfo.getUserId());
+        for (WorkStaffCertificate entity : list) {
+            entity.setStaffId(workStaffBasicInfo.getId());
+            WorkStaffCertificate workStaffCertificate=dao.get(entity.getId());
+            if(workStaffCertificate==null){
+                entity.setCreateBy(u);
+                entity.setCreateDate(new Date());
+                entity.setUpdateBy(u);
+                entity.setUpdateDate(new Date());
+                dao.insert(entity);
+            }else{
+                this.save(entity);
+            }
+            if(entity!=null&&"1".equals(entity.getDelFlag())){
+                dao.deleteByLogic(entity);
+                continue;
+            }
+            flag =true;
+        }
+        dao.updateFalt(workStaffBasicInfo.getId());
+        return flag;
+    }
+
+    public void querys(WorkStaffBasicInfo workStaffBasicInfo) {
+        SimpleDateFormat dateFormat1 = new SimpleDateFormat("yyyy-MM-dd");
+        if(workStaffBasicInfo==null|| StringUtils.isBlank(workStaffBasicInfo.getId())){
+            return;
+        }
+        WorkStaffCertificate entity = new WorkStaffCertificate();
+        entity.setStaffId(workStaffBasicInfo.getId());
+        List<WorkStaffCertificate> list=this.findList(entity);
+        List<WorkStaffCertificate> newList=Lists.newArrayList();
+        if(list!=null&&list.size()>0){//修改
+            for(WorkStaffCertificate workStaffCertificate:list){
+                Class<? extends WorkStaffCertificate> newClass = workStaffCertificate.getClass();
+                Field[] declaredFields = newClass.getDeclaredFields();
+                for (Field field : declaredFields) {
+                    String name = field.getName();
+                    if("name".equals(name)||"num".equals(name)||"issuingAuthority".equals(name)||"issuingDate".equals(name)||"registDate".equals(name)
+                            || "registNum".equals(name)||"major".equals(name)||"grade".equals(name)
+                            ||"issType".equals(name)||"filePath".equals(name)||"fileName".equals(name)){
+                        String setMethod = "set"+name.substring(0,1).toUpperCase()+name.substring(1);
+                        String getMethod = "get"+name.substring(0,1).toUpperCase()+name.substring(1);
+                        WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+                        workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+                        workStaffAchivesLog.setModule("执业资格证书");
+                        workStaffAchivesLog.setSonId(workStaffCertificate.getId());
+                        workStaffAchivesLog.setFields(name);
+                        workStaffAchivesLog.setType("修改");
+                        workStaffAchivesLog.setState("1");
+                        List<WorkStaffAchivesLog> logs=workStaffAchivesLogService.findList(workStaffAchivesLog);
+                        try {
+                            Object newInvoke = newClass.getMethod(getMethod).invoke(workStaffCertificate);//修改后
+                            if(newInvoke instanceof String){
+                                Method setReadOnly = workStaffCertificate.getClass().getMethod(setMethod, String.class);
+                                if(logs!=null&&logs.size()>0){
+                                    setReadOnly.invoke(workStaffCertificate,logs.get(0).getNewKey());
+                                }
+                            }
+                            if(newInvoke instanceof Date){//日期
+                                Method setReadOnly = workStaffCertificate.getClass().getMethod(setMethod, Date.class);
+                                if(logs!=null&&logs.size()>0){
+                                    Date myDate = dateFormat1.parse(logs.get(0).getNewKey());
+                                    setReadOnly.invoke(workStaffCertificate,myDate);
+                                }
+                            }
+                        } catch (NoSuchMethodException e) {
+                            e.printStackTrace();
+                        } catch (IllegalAccessException e) {
+                            e.printStackTrace();
+                        } catch (InvocationTargetException e) {
+                            e.printStackTrace();
+                        } catch (ParseException e) {
+                            e.printStackTrace();
+                        }
+                    }
+                }
+                newList.add(workStaffCertificate);
+            }
+        }
+        //新增
+        WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+        workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+        workStaffAchivesLog.setModule("执业资格证书");
+        workStaffAchivesLog.setType("新增");
+        workStaffAchivesLog.setState("1");
+        List<WorkStaffAchivesLog> sonIds=workStaffAchivesLogService.findSonId(workStaffAchivesLog);
+        if(sonIds!=null&&sonIds.size()>0){
+            for(WorkStaffAchivesLog w:sonIds){
+                workStaffAchivesLog.setSonId(w.getSonId());
+                WorkStaffCertificate workStaffCertificate = new WorkStaffCertificate();
+                workStaffCertificate.setId(w.getSonId());
+                workStaffCertificate.setDelFlag("0");
+                workStaffCertificate.setStaffId(workStaffBasicInfo.getId());
+                Class<? extends WorkStaffCertificate> newClass = workStaffCertificate.getClass();
+                Field[] declaredFields = newClass.getDeclaredFields();
+                for (Field field : declaredFields) {
+                    String name = field.getName();
+                    if("name".equals(name)||"num".equals(name)||"issuingAuthority".equals(name)||"issuingDate".equals(name)||"registDate".equals(name)
+                            || "registNum".equals(name)||"major".equals(name)||"grade".equals(name)
+                            ||"issType".equals(name)||"filePath".equals(name)||"fileName".equals(name)){
+                        String setMethod = "set"+name.substring(0,1).toUpperCase()+name.substring(1);
+                        String getMethod = "get"+name.substring(0,1).toUpperCase()+name.substring(1);
+                        workStaffAchivesLog.setFields(name);
+                        List<WorkStaffAchivesLog> logs=workStaffAchivesLogService.findList(workStaffAchivesLog);
+                        try {
+                            if("registDate".equals(name)||"issuingDate".equals(name)){//日期
+                                Method setReadOnly = workStaffCertificate.getClass().getMethod(setMethod, Date.class);
+                                if(logs!=null&&logs.size()>0){
+                                    Date myDate = dateFormat1.parse(logs.get(0).getNewKey());
+                                    setReadOnly.invoke(workStaffCertificate,myDate);
+                                }
+                            }else{
+                                Method setReadOnly = workStaffCertificate.getClass().getMethod(setMethod, String.class);
+                                if(logs!=null&&logs.size()>0){
+                                    setReadOnly.invoke(workStaffCertificate,logs.get(0).getNewKey());
+                                }
+                            }
+                        } catch (NoSuchMethodException e) {
+                            e.printStackTrace();
+                        } catch (IllegalAccessException e) {
+                            e.printStackTrace();
+                        } catch (InvocationTargetException e) {
+                            e.printStackTrace();
+                        } catch (ParseException e) {
+                            e.printStackTrace();
+                        }
+                    }
+                }
+                newList.add(workStaffCertificate);
+            }
+        }
+        //删除
+        WorkStaffAchivesLog delLog=new WorkStaffAchivesLog();
+        delLog.setStaffId(workStaffBasicInfo.getId());
+        delLog.setModule("执业资格证书");
+        delLog.setType("删除");
+        workStaffAchivesLog.setState("1");
+        List<WorkStaffAchivesLog> dellogs=workStaffAchivesLogService.findList(delLog);
+        if(dellogs!=null&&dellogs.size()>0){
+            for(WorkStaffAchivesLog w:dellogs){
+                newList.remove(dao.get(w.getSonId()));
+            }
+        }
+        workStaffBasicInfo.setCertificateList(newList);
+    }
+    @Transactional(readOnly = false)
+    public void saveEdu(WorkStaffBasicInfo workStaffBasicInfo) {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        List<WorkStaffCertificate> certificateList =workStaffBasicInfo.getCertificateList();
+        if(certificateList!=null&&certificateList.size()>0){
+            for(WorkStaffCertificate newCertificate:certificateList){
+                Class<? extends WorkStaffCertificate> newClass = newCertificate.getClass();
+                Field[] declaredFields = newClass.getDeclaredFields();
+                if(newCertificate.getId()!=null&&!"1".equals(newCertificate.getDelFlag())&&!"".equals(newCertificate.getId())){
+                    if(newCertificate.getFile()!=null&&!newCertificate.getFile().isEmpty()&&newCertificate.getFile().getSize()>0){
+                        MultipartFile file = newCertificate.getFile();
+                        newCertificate.setFilePath(this.uploadFile(file,newCertificate.getFilePath()));
+                    }
+                    WorkStaffCertificate oldCertificate=this.get(newCertificate.getId());
+                    if(oldCertificate!=null){
+                        Class<? extends WorkStaffCertificate> oldClass = oldCertificate.getClass();
+                        for (Field field : declaredFields) {
+                            String name = field.getName();
+                            if("name".equals(name)||"num".equals(name)||"issuingAuthority".equals(name)||"issuingDate".equals(name)||"registDate".equals(name)
+                                    || "registNum".equals(name)||"major".equals(name)||"grade".equals(name)
+                                    ||"issType".equals(name)||"filePath".equals(name)||"fileName".equals(name)){
+                                String methodName = "get"+name.substring(0,1).toUpperCase()+name.substring(1);
+                                WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+                                workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+                                workStaffAchivesLog.setModule("执业资格证书");
+                                workStaffAchivesLog.setSonId(newCertificate.getId());
+                                workStaffAchivesLog.setFields(name);
+                                workStaffAchivesLog.setState("1");
+                                try {
+                                    Object newInvoke = newClass.getMethod(methodName).invoke(newCertificate);//修改后
+                                    Object oldInvoke = oldClass.getMethod(methodName).invoke(oldCertificate);//修改前
+                                    String describes=EDU_MAP.get(name);
+                                    if(newInvoke instanceof String){
+                                        String newValue=newInvoke.toString();
+                                        String oldValue=oldInvoke.toString();
+                                        if(!newValue.equals(oldValue)){
+                                            if("name".equals(name)){
+                                                workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                                        "执业资格证书",describes,name,
+                                                        DictUtils.getMainDictLabel(oldValue,"certificate_type",""),
+                                                        DictUtils.getMainDictLabel(newValue,"certificate_type",""),
+                                                        oldValue,newValue,newCertificate.getId(),"修改");
+                                            }else{
+                                                workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                                        "执业资格证书",describes,name,
+                                                        oldInvoke.toString(),newInvoke.toString(),
+                                                        oldInvoke.toString(),newInvoke.toString(),newCertificate.getId(),"修改");
+                                            }
+                                        }
+                                    }
+                                    if(newInvoke instanceof Date){//日期
+                                        String newDate="";
+                                        String oldDate="";
+                                        if(newInvoke!=null){
+                                            newDate=sdf.format(newInvoke);
+                                        }
+                                        if (oldInvoke!=null){
+                                            oldDate=sdf.format(oldInvoke);
+                                        }
+                                        if(!newDate.equals(oldDate)){
+                                            workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                                    "执业资格证书",describes,name,
+                                                    oldDate,newDate,oldDate,newDate,newCertificate.getId(),"修改");
+                                        }
+                                    }
+                                } catch (NoSuchMethodException e) {
+                                    e.printStackTrace();
+                                } catch (IllegalAccessException e) {
+                                    e.printStackTrace();
+                                } catch (InvocationTargetException e) {
+                                    e.printStackTrace();
+                                }
+                            }
+                        }
+                    }
+                }else if((newCertificate.getId()==null||"".equals(newCertificate.getId()))&&"0".equals(newCertificate.getDelFlag())){//新增
+                    if(newCertificate.getFile()!=null&&!newCertificate.getFile().isEmpty()&&newCertificate.getFile().getSize()>0){
+                        MultipartFile file = newCertificate.getFile();
+                        newCertificate.setFilePath(this.uploadFile(file,newCertificate.getFilePath()));
+                    }
+                    String newId=IdGen.uuid();
+                    for (Field field : declaredFields) {
+                        String name = field.getName();
+                        if("name".equals(name)||"num".equals(name)||"issuingAuthority".equals(name)||"issuingDate".equals(name)||"registDate".equals(name)
+                                || "registNum".equals(name)||"major".equals(name)||"grade".equals(name)
+                                ||"issType".equals(name)||"filePath".equals(name)||"fileName".equals(name)){
+                            String methodName = "get"+name.substring(0,1).toUpperCase()+name.substring(1);
+                            WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+                            workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+                            workStaffAchivesLog.setModule("执业资格证书");
+                            workStaffAchivesLog.setSonId(newId);
+                            workStaffAchivesLog.setFields(name);
+                            workStaffAchivesLog.setState("1");
+                            try {
+                                Object newInvoke = newClass.getMethod(methodName).invoke(newCertificate);//修改后
+                                String describes=EDU_MAP.get(name);
+                                if(newInvoke instanceof String){
+                                    String newValue=newInvoke.toString();
+                                    if("name".equals(name)){
+                                        workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                                "执业资格证书",describes,name,
+                                                "",
+                                                DictUtils.getMainDictLabel(newValue,"certificate_type",""),
+                                                "",newValue,newId,"新增");
+                                    }else{
+                                        workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                                "执业资格证书",describes,name,
+                                                "",newInvoke.toString(),
+                                                "",newInvoke.toString(),newId,"新增");
+                                    }
+                                }
+                                if(newInvoke instanceof Date){//日期
+                                    String newDate=sdf.format(newInvoke);
+                                    workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                            "执业资格证书",describes,name,
+                                            "",newDate,"",newDate,newId,"新增");
+                                };
+                            } catch (NoSuchMethodException e) {
+                                e.printStackTrace();
+                            } catch (IllegalAccessException e) {
+                                e.printStackTrace();
+                            } catch (InvocationTargetException e) {
+                                e.printStackTrace();
+                            }
+                        }
+                    }
+                }else if(newCertificate.getId()!=null&&"1".equals(newCertificate.getDelFlag())&&!"".equals(newCertificate.getId())){//删除
+                    WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+                    workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+                    workStaffAchivesLog.setModule("执业资格证书");
+                    workStaffAchivesLog.setSonId(newCertificate.getId());
+                    workStaffAchivesLog.setType("删除");
+                    workStaffAchivesLog.setState("1");
+                    workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                            "执业资格证书","","",
+                            "","",
+                            "","",newCertificate.getId(),"删除");
+                }
+            }
+        }
+    }
+}

+ 483 - 0
src/main/java/com/jeeplus/modules/workstaff/service/WorkStaffEducationService.java

@@ -0,0 +1,483 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workstaff.service;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+import java.lang.reflect.Field;
+import java.util.Map;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.jeeplus.common.bos.BOSClientUtil;
+import com.jeeplus.common.config.Global;
+import com.jeeplus.common.oss.OSSClientUtil;
+import com.jeeplus.common.utils.DateUtils;
+import com.jeeplus.common.utils.IdGen;
+import com.jeeplus.common.utils.StringUtils;
+import com.jeeplus.modules.sys.dao.UserDao;
+import com.jeeplus.modules.sys.entity.User;
+import com.jeeplus.modules.sys.utils.DictUtils;
+import com.jeeplus.modules.workstaff.entity.WorkStaffBasicInfo;
+import com.jeeplus.modules.workstaffachiveslog.entity.WorkStaffAchivesLog;
+import com.jeeplus.modules.workstaffachiveslog.service.WorkStaffAchivesLogService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.jeeplus.common.persistence.Page;
+import com.jeeplus.common.service.CrudService;
+import com.jeeplus.modules.workstaff.entity.WorkStaffEducation;
+import com.jeeplus.modules.workstaff.dao.WorkStaffEducationDao;
+import org.springframework.web.multipart.MultipartFile;
+
+/**
+ * 教育经历Service
+ * @author ssrh
+ * @version 2018-07-27
+ */
+@Service
+@Transactional(readOnly = true)
+public class WorkStaffEducationService extends CrudService<WorkStaffEducationDao, WorkStaffEducation> {
+    @Autowired
+    private WorkStaffAchivesLogService workStaffAchivesLogService;
+    @Autowired
+    private UserDao userDao;
+
+	public WorkStaffEducation get(String id) {
+		return super.get(id);
+	}
+	
+	public List<WorkStaffEducation> findList(WorkStaffEducation workStaffEducation) {
+		return super.findList(workStaffEducation);
+	}
+	
+	public Page<WorkStaffEducation> findPage(Page<WorkStaffEducation> page, WorkStaffEducation workStaffEducation) {
+		return super.findPage(page, workStaffEducation);
+	}
+	
+	@Transactional(readOnly = false)
+	public void save(WorkStaffEducation workStaffEducation) {
+		super.save(workStaffEducation);
+	}
+	
+	@Transactional(readOnly = false)
+	public void delete(WorkStaffEducation workStaffEducation) {
+		super.delete(workStaffEducation);
+	}
+
+
+    public boolean save(WorkStaffBasicInfo workStaffBasicInfo,boolean first) {
+        if(workStaffBasicInfo==null|| StringUtils.isBlank(workStaffBasicInfo.getId())){
+            return false;
+        }
+        List<WorkStaffEducation> list = workStaffBasicInfo.getEducationList();
+        if(list==null||list.size()<=0){
+            return false;
+        }
+        boolean flag = false;
+        for (WorkStaffEducation entity : list) {
+            if(entity!=null&&"1".equals(entity.getDelFlag())&&StringUtils.isBlank(entity.getId())){
+                continue;
+            }
+            if(entity!=null&&"1".equals(entity.getDelFlag())){
+                dao.deleteByLogic(entity);
+                continue;
+            }
+            if (entity!=null){
+                if(entity.getDegreePhotoFile()!=null&&!entity.getDegreePhotoFile().isEmpty()&&entity.getDegreePhotoFile().getSize()>0){
+                    MultipartFile file = entity.getDegreePhotoFile();
+                    entity.setDegreePhoto(this.uploadFile(file,entity.getDegreePhoto()));
+                }
+                if(entity.getEduPhotoFile()!=null&&!entity.getEduPhotoFile().isEmpty()&&entity.getEduPhotoFile().getSize()>0){
+                    MultipartFile file = entity.getEduPhotoFile();
+                    entity.setEduPhoto(this.uploadFile(file,entity.getEduPhoto()));
+                }
+                entity.setStaff(workStaffBasicInfo.getId());
+                this.save(entity);
+                if(first){
+                    entity.setId(null);
+                    entity.setDegreePhoto("");
+                    entity.setEduPhoto("");
+                }
+                flag =true;
+            }
+        }
+        return flag;
+    }
+
+    public String uploadFile(MultipartFile file, String filePath){
+	    String date = DateUtils.formatDate(new Date(),"yyMMddHHmm");
+	    try {
+            if (file != null && file.getSize() > 0) {
+                String path = new StringBuilder("/employeeInfo/").append(date)
+                        .append(file.getOriginalFilename()).toString();
+                InputStream inputStream = file.getInputStream();
+                BOSClientUtil bosClientUtil = new BOSClientUtil();
+                String url = bosClientUtil.upload(path, inputStream);
+                return url;
+            }
+        }catch (Exception e){
+            logger.error("上传文件失败!");
+        }
+	    return null;
+    }
+
+    public void query(WorkStaffBasicInfo workStaffBasicInfo) {
+        if(workStaffBasicInfo==null|| StringUtils.isBlank(workStaffBasicInfo.getId())){
+            return;
+        }
+        WorkStaffEducation entity = new WorkStaffEducation();
+        entity.setStaff(workStaffBasicInfo.getId());
+        workStaffBasicInfo.setEducationList(this.findList(entity));
+    }
+
+    private static Map<String,String> EDU_MAP = Maps.newHashMap();//教育经历
+
+    static{//教育经历
+        EDU_MAP.put("school", "毕业院校");
+        EDU_MAP.put("major", "所学专业");
+        EDU_MAP.put("edu", "学历");
+        EDU_MAP.put("degree", "学位");
+        EDU_MAP.put("eduType", "学历性质");
+        EDU_MAP.put("startDate", "入学日期");
+        EDU_MAP.put("endDate", "毕业日期");
+        EDU_MAP.put("eduPhoto", "学历证书");
+        EDU_MAP.put("degreePhoto", "学位证书");
+    }
+    public boolean saveApply(WorkStaffBasicInfo workStaffBasicInfo,boolean first) {
+        if(workStaffBasicInfo==null|| StringUtils.isBlank(workStaffBasicInfo.getId())){
+            return false;
+        }
+        List<WorkStaffEducation> list = workStaffBasicInfo.getEducationList();
+        if(list==null||list.size()<=0){
+            return false;
+        }
+        boolean flag = false;
+        User u=userDao.get(workStaffBasicInfo.getUserId());
+        for (WorkStaffEducation entity : list) {
+            entity.setStaff(workStaffBasicInfo.getId());
+            WorkStaffEducation workStaffEducation=dao.get(entity.getId());
+            if(workStaffEducation==null){
+                entity.setCreateBy(u);
+                entity.setCreateDate(new Date());
+                entity.setUpdateBy(u);
+                entity.setUpdateDate(new Date());
+                dao.insert(entity);
+            }else{
+                this.save(entity);
+            }
+            if(entity!=null&&"1".equals(entity.getDelFlag())){
+                dao.deleteByLogic(entity);
+                continue;
+            }
+            flag =true;
+        }
+        dao.updateFalt(workStaffBasicInfo.getId());
+        return flag;
+    }
+    public void querys(WorkStaffBasicInfo workStaffBasicInfo) {
+        SimpleDateFormat dateFormat1 = new SimpleDateFormat("yyyy-MM-dd");
+        if(workStaffBasicInfo==null|| StringUtils.isBlank(workStaffBasicInfo.getId())){
+            return;
+        }
+        WorkStaffEducation entity = new WorkStaffEducation();
+        entity.setStaff(workStaffBasicInfo.getId());
+        List<WorkStaffEducation> list=this.findList(entity);
+        List<WorkStaffEducation> newList=Lists.newArrayList();
+        if(list!=null&&list.size()>0){//修改
+            for(WorkStaffEducation workStaffEducation:list){
+                Class<? extends WorkStaffEducation> newClass = workStaffEducation.getClass();
+                Field[] declaredFields = newClass.getDeclaredFields();
+                for (Field field : declaredFields) {
+                    String name = field.getName();
+                    if("school".equals(name)||"major".equals(name)||"edu".equals(name)||"degree".equals(name)||"eduType".equals(name)
+                            || "startDate".equals(name)||"endDate".equals(name)||"eduPhoto".equals(name)||"degreePhoto".equals(name)){
+                        String setMethod = "set"+name.substring(0,1).toUpperCase()+name.substring(1);
+                        String getMethod = "get"+name.substring(0,1).toUpperCase()+name.substring(1);
+                        WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+                        workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+                        workStaffAchivesLog.setModule("教育经历");
+                        workStaffAchivesLog.setSonId(workStaffEducation.getId());
+                        workStaffAchivesLog.setFields(name);
+                        workStaffAchivesLog.setType("修改");
+                        workStaffAchivesLog.setState("1");
+                        List<WorkStaffAchivesLog> logs=workStaffAchivesLogService.findList(workStaffAchivesLog);
+                        try {
+                            Object newInvoke = newClass.getMethod(getMethod).invoke(workStaffEducation);//修改后
+                            if(newInvoke instanceof String){
+                                Method setReadOnly = workStaffEducation.getClass().getMethod(setMethod, String.class);
+                                if(logs!=null&&logs.size()>0){
+                                    setReadOnly.invoke(workStaffEducation,logs.get(0).getNewKey());
+                                }
+                            }
+                            if(newInvoke instanceof Date){//日期
+                                Method setReadOnly = workStaffEducation.getClass().getMethod(setMethod, Date.class);
+                                if(logs!=null&&logs.size()>0){
+                                    Date myDate = dateFormat1.parse(logs.get(0).getNewKey());
+                                    setReadOnly.invoke(workStaffEducation,myDate);
+                                }
+                            }
+                        } catch (NoSuchMethodException e) {
+                            e.printStackTrace();
+                        } catch (IllegalAccessException e) {
+                            e.printStackTrace();
+                        } catch (InvocationTargetException e) {
+                            e.printStackTrace();
+                        } catch (ParseException e) {
+                            e.printStackTrace();
+                        }
+                    }
+                }
+                newList.add(workStaffEducation);
+            }
+        }
+        //新增
+        WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+        workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+        workStaffAchivesLog.setModule("教育经历");
+        workStaffAchivesLog.setType("新增");
+        workStaffAchivesLog.setState("1");
+        List<WorkStaffAchivesLog> sonIds=workStaffAchivesLogService.findSonId(workStaffAchivesLog);
+        if(sonIds!=null&&sonIds.size()>0){
+            for(WorkStaffAchivesLog w:sonIds){
+                workStaffAchivesLog.setSonId(w.getSonId());
+                WorkStaffEducation workStaffEducation = new WorkStaffEducation();
+                workStaffEducation.setId(w.getSonId());
+                workStaffEducation.setDelFlag("0");
+                workStaffEducation.setStaff(workStaffBasicInfo.getId());
+                Class<? extends WorkStaffEducation> newClass = workStaffEducation.getClass();
+                Field[] declaredFields = newClass.getDeclaredFields();
+                for (Field field : declaredFields) {
+                    String name = field.getName();
+                    if("school".equals(name)||"major".equals(name)||"edu".equals(name)||"degree".equals(name)||"eduType".equals(name)
+                            || "startDate".equals(name)||"endDate".equals(name)||"eduPhoto".equals(name)||"degreePhoto".equals(name)){
+                        String setMethod = "set"+name.substring(0,1).toUpperCase()+name.substring(1);
+                        String getMethod = "get"+name.substring(0,1).toUpperCase()+name.substring(1);
+                        workStaffAchivesLog.setFields(name);
+                        List<WorkStaffAchivesLog> logs=workStaffAchivesLogService.findList(workStaffAchivesLog);
+                        try {
+                            if("startDate".equals(name)||"endDate".equals(name)){//日期
+                                Method setReadOnly = workStaffEducation.getClass().getMethod(setMethod, Date.class);
+                                if(logs!=null&&logs.size()>0){
+                                    Date myDate = dateFormat1.parse(logs.get(0).getNewKey());
+                                    setReadOnly.invoke(workStaffEducation,myDate);
+                                }
+                            }else{
+                                Method setReadOnly = workStaffEducation.getClass().getMethod(setMethod, String.class);
+                                if(logs!=null&&logs.size()>0){
+                                    setReadOnly.invoke(workStaffEducation,logs.get(0).getNewKey());
+                                }
+                            }
+                        } catch (NoSuchMethodException e) {
+                            e.printStackTrace();
+                        } catch (IllegalAccessException e) {
+                            e.printStackTrace();
+                        } catch (InvocationTargetException e) {
+                            e.printStackTrace();
+                        } catch (ParseException e) {
+                            e.printStackTrace();
+                        }
+                    }
+                }
+                newList.add(workStaffEducation);
+            }
+        }
+        //删除
+        WorkStaffAchivesLog delLog=new WorkStaffAchivesLog();
+        delLog.setStaffId(workStaffBasicInfo.getId());
+        delLog.setModule("教育经历");
+        delLog.setType("删除");
+        workStaffAchivesLog.setState("1");
+        List<WorkStaffAchivesLog> dellogs=workStaffAchivesLogService.findList(delLog);
+        if(dellogs!=null&&dellogs.size()>0){
+            for(WorkStaffAchivesLog w:dellogs){
+                newList.remove(dao.get(w.getSonId()));
+            }
+        }
+        workStaffBasicInfo.setEducationList(newList);
+    }
+
+    @Transactional(readOnly = false)
+    public void saveEdu(WorkStaffBasicInfo workStaffBasicInfo) {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        List<WorkStaffEducation> educationList =workStaffBasicInfo.getEducationList();
+        if(educationList!=null&&educationList.size()>0){
+            for(WorkStaffEducation newEducation:educationList){
+                Class<? extends WorkStaffEducation> newClass = newEducation.getClass();
+                Field[] declaredFields = newClass.getDeclaredFields();
+                if(newEducation.getId()!=null&&!"1".equals(newEducation.getDelFlag())&&!"".equals(newEducation.getId())){
+                    if(newEducation.getDegreePhotoFile()!=null&&!newEducation.getDegreePhotoFile().isEmpty()&&newEducation.getDegreePhotoFile().getSize()>0){
+                        MultipartFile file = newEducation.getDegreePhotoFile();
+                        newEducation.setDegreePhoto(this.uploadFile(file,newEducation.getDegreePhoto()));
+                    }
+                    if(newEducation.getEduPhotoFile()!=null&&!newEducation.getEduPhotoFile().isEmpty()&&newEducation.getEduPhotoFile().getSize()>0){
+                        MultipartFile file = newEducation.getEduPhotoFile();
+                        newEducation.setEduPhoto(this.uploadFile(file,newEducation.getEduPhoto()));
+                    }
+                    WorkStaffEducation oldEducation=this.get(newEducation.getId());
+                    if(oldEducation!=null){
+                        Class<? extends WorkStaffEducation> oldClass = oldEducation.getClass();
+                        for (Field field : declaredFields) {
+                            String name = field.getName();
+                            if("school".equals(name)||"major".equals(name)||"edu".equals(name)||"degree".equals(name)||"eduType".equals(name)
+                                    || "startDate".equals(name)||"endDate".equals(name)||"eduPhoto".equals(name)||"degreePhoto".equals(name)
+                                    ||"degreePhotoFile".equals(name)||"eduPhotoFile".equals(name)){
+                                String methodName = "get"+name.substring(0,1).toUpperCase()+name.substring(1);
+                                WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+                                workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+                                workStaffAchivesLog.setModule("教育经历");
+                                workStaffAchivesLog.setSonId(newEducation.getId());
+                                workStaffAchivesLog.setFields(name);
+                                workStaffAchivesLog.setState("1");
+                                try {
+                                    Object newInvoke = newClass.getMethod(methodName).invoke(newEducation);//修改后
+                                    Object oldInvoke = oldClass.getMethod(methodName).invoke(oldEducation);//修改前
+                                    String describes=EDU_MAP.get(name);
+                                    if(newInvoke instanceof String){
+                                        String newValue=newInvoke.toString();
+                                        String oldValue=oldInvoke.toString();
+                                        if(!newValue.equals(oldValue)){
+                                            if("edu".equals(name)){
+                                                workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                                        "教育经历",describes,name,
+                                                        DictUtils.getDictLabel(oldValue,"education_level",""),
+                                                        DictUtils.getDictLabel(newValue,"education_level",""),
+                                                        oldValue,newValue,newEducation.getId(),"修改");
+                                            }else if("degree".equals(name)){
+                                                workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                                        "教育经历",describes,name,
+                                                        DictUtils.getDictLabel(oldValue,"degree_level",""),
+                                                        DictUtils.getDictLabel(newValue,"degree_level",""),
+                                                        oldValue,newValue,newEducation.getId(),"修改");
+                                            }else if("eduType".equals(name)){
+                                                workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                                        "教育经历",describes,name,
+                                                        DictUtils.getDictLabel(oldValue,"edu_type",""),
+                                                        DictUtils.getDictLabel(newValue,"edu_type",""),
+                                                        oldValue,newValue,newEducation.getId(),"修改");
+                                            }else{
+                                                workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                                        "教育经历",describes,name,
+                                                        oldInvoke.toString(),newInvoke.toString(),
+                                                        oldInvoke.toString(),newInvoke.toString(),newEducation.getId(),"修改");
+                                            }
+                                        }
+                                    }
+                                    if(newInvoke instanceof Date){//日期
+                                        String newDate="";
+                                        String oldDate="";
+                                        if(newInvoke!=null){
+                                            newDate=sdf.format(newInvoke);
+                                        }
+                                        if (oldInvoke!=null){
+                                            oldDate=sdf.format(oldInvoke);
+                                        }
+                                        if(!newDate.equals(oldDate)){
+                                            workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                                    "教育经历",describes,name,
+                                                    oldDate,newDate,oldDate,newDate,newEducation.getId(),"修改");
+                                        }
+                                    }
+                                } catch (NoSuchMethodException e) {
+                                    e.printStackTrace();
+                                } catch (IllegalAccessException e) {
+                                    e.printStackTrace();
+                                } catch (InvocationTargetException e) {
+                                    e.printStackTrace();
+                                }
+                            }
+                        }
+
+                    }
+                }else if((newEducation.getId()==null||"".equals(newEducation.getId()))&&"0".equals(newEducation.getDelFlag())){//新增
+                    if(newEducation.getDegreePhotoFile()!=null&&!newEducation.getDegreePhotoFile().isEmpty()&&newEducation.getDegreePhotoFile().getSize()>0){
+                        MultipartFile file = newEducation.getDegreePhotoFile();
+                        newEducation.setDegreePhoto(this.uploadFile(file,newEducation.getDegreePhoto()));
+                    }
+                    if(newEducation.getEduPhotoFile()!=null&&!newEducation.getEduPhotoFile().isEmpty()&&newEducation.getEduPhotoFile().getSize()>0){
+                        MultipartFile file = newEducation.getEduPhotoFile();
+                        newEducation.setEduPhoto(this.uploadFile(file,newEducation.getEduPhoto()));
+                    }
+                    String newId=IdGen.uuid();
+                    for (Field field : declaredFields) {
+                        String name = field.getName();
+                        if("school".equals(name)||"major".equals(name)||"edu".equals(name)||"degree".equals(name)||"eduType".equals(name)
+                                || "startDate".equals(name)||"endDate".equals(name)||"eduPhoto".equals(name)||"degreePhoto".equals(name)
+                                ||"degreePhotoFile".equals(name)||"eduPhotoFile".equals(name)){
+                            String methodName = "get"+name.substring(0,1).toUpperCase()+name.substring(1);
+                            WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+                            workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+                            workStaffAchivesLog.setModule("教育经历");
+                            workStaffAchivesLog.setSonId(newId);
+                            workStaffAchivesLog.setFields(name);
+                            workStaffAchivesLog.setState("1");
+                            try {
+                                Object newInvoke = newClass.getMethod(methodName).invoke(newEducation);//修改后
+                                String describes=EDU_MAP.get(name);
+                                if(newInvoke instanceof String){
+                                    String newValue=newInvoke.toString();
+                                    if("edu".equals(name)){
+                                        workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                                "教育经历",describes,name,
+                                                "",
+                                                DictUtils.getDictLabel(newValue,"education_level",""),
+                                                "",newValue,newId,"新增");
+                                    }else if("degree".equals(name)){
+                                        workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                                "教育经历",describes,name,
+                                                "",
+                                                DictUtils.getDictLabel(newValue,"degree_level",""),
+                                                "",newValue,newId,"新增");
+                                    }else if("eduType".equals(name)){
+                                        workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                                "教育经历",describes,name,
+                                                "",
+                                                DictUtils.getDictLabel(newValue,"edu_type",""),
+                                                "",newValue,newId,"新增");
+                                    }else{
+                                        workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                                "教育经历",describes,name,
+                                                "",newInvoke.toString(),
+                                                "",newInvoke.toString(),newId,"新增");
+                                    }
+                                }
+                                if(newInvoke instanceof Date){//日期
+                                    String newDate=sdf.format(newInvoke);
+                                    workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                            "教育经历",describes,name,
+                                            "",newDate,"",newDate,newId,"新增");
+                                };
+                            } catch (NoSuchMethodException e) {
+                                e.printStackTrace();
+                            } catch (IllegalAccessException e) {
+                                e.printStackTrace();
+                            } catch (InvocationTargetException e) {
+                                e.printStackTrace();
+                            }
+                        }
+                    }
+                }else if(newEducation.getId()!=null&&"1".equals(newEducation.getDelFlag())&&!"".equals(newEducation.getId())){//删除
+                    WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+                    workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+                    workStaffAchivesLog.setModule("教育经历");
+                    workStaffAchivesLog.setSonId(newEducation.getId());
+                    workStaffAchivesLog.setType("删除");
+                    workStaffAchivesLog.setState("1");
+                    workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                            "教育经历","","",
+                            "","",
+                            "","",newEducation.getId(),"删除");
+                }
+            }
+        }
+    }
+}

+ 389 - 0
src/main/java/com/jeeplus/modules/workstaff/service/WorkStaffExperienceService.java

@@ -0,0 +1,389 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workstaff.service;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.jeeplus.common.utils.IdGen;
+import com.jeeplus.common.utils.StringUtils;
+import com.jeeplus.modules.sys.dao.UserDao;
+import com.jeeplus.modules.sys.entity.User;
+import com.jeeplus.modules.sys.utils.DictUtils;
+import com.jeeplus.modules.workstaff.entity.WorkStaffBasicInfo;
+import com.jeeplus.modules.workstaff.entity.WorkStaffEducation;
+import com.jeeplus.modules.workstaffachiveslog.entity.WorkStaffAchivesLog;
+import com.jeeplus.modules.workstaffachiveslog.service.WorkStaffAchivesLogService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.jeeplus.common.persistence.Page;
+import com.jeeplus.common.service.CrudService;
+import com.jeeplus.modules.workstaff.entity.WorkStaffExperience;
+import com.jeeplus.modules.workstaff.dao.WorkStaffExperienceDao;
+import org.springframework.web.multipart.MultipartFile;
+
+/**
+ * 工作经历Service
+ * @author ssrh
+ * @version 2018-07-27
+ */
+@Service
+@Transactional(readOnly = true)
+public class WorkStaffExperienceService extends CrudService<WorkStaffExperienceDao, WorkStaffExperience> {
+    @Autowired
+    private WorkStaffAchivesLogService workStaffAchivesLogService;
+    @Autowired
+    private UserDao userDao;
+	public WorkStaffExperience get(String id) {
+		return super.get(id);
+	}
+	
+	public List<WorkStaffExperience> findList(WorkStaffExperience workStaffExperience) {
+		return super.findList(workStaffExperience);
+	}
+	
+	public Page<WorkStaffExperience> findPage(Page<WorkStaffExperience> page, WorkStaffExperience workStaffExperience) {
+		return super.findPage(page, workStaffExperience);
+	}
+	
+	@Transactional(readOnly = false)
+	public void save(WorkStaffExperience workStaffExperience) {
+		super.save(workStaffExperience);
+	}
+	
+	@Transactional(readOnly = false)
+	public void delete(WorkStaffExperience workStaffExperience) {
+		super.delete(workStaffExperience);
+	}
+
+
+    public boolean save(WorkStaffBasicInfo workStaffBasicInfo,boolean first) {
+        if(workStaffBasicInfo==null|| StringUtils.isBlank(workStaffBasicInfo.getId())){
+            return false;
+        }
+        List<WorkStaffExperience> experienceList = workStaffBasicInfo.getExperienceList();
+        if(experienceList==null||experienceList.size()<=0){
+            return false;
+        }
+        boolean flag = false;
+        for (WorkStaffExperience entity : experienceList) {
+            if(entity!=null&&"1".equals(entity.getDelFlag())&&StringUtils.isBlank(entity.getId())){
+                continue;
+            }
+            if(entity!=null&&"1".equals(entity.getDelFlag())){
+                dao.deleteByLogic(entity);
+                continue;
+            }
+            if (entity!=null){
+                entity.setStaffId(workStaffBasicInfo.getId());
+                this.save(entity);
+                if(first){
+                    entity.setId(null);
+                }
+                flag =true;
+            }
+        }
+        return flag;
+    }
+
+    public void query(WorkStaffBasicInfo workStaffBasicInfo) {
+        if(workStaffBasicInfo==null|| StringUtils.isBlank(workStaffBasicInfo.getId())){
+            return;
+        }
+        WorkStaffExperience entity = new WorkStaffExperience();
+        entity.setStaffId(workStaffBasicInfo.getId());
+        workStaffBasicInfo.setExperienceList(this.findList(entity));
+    }
+    private static Map<String,String> EDU_MAP = Maps.newHashMap();//工作经历
+
+    static{//教育经历
+        EDU_MAP.put("company", "所在单位");
+        EDU_MAP.put("dept", "工作部门");
+        EDU_MAP.put("duty", "职务或岗位");
+        EDU_MAP.put("startDate", "起始日期");
+        EDU_MAP.put("endDate", "终止日期");
+        EDU_MAP.put("certifier", "证明人");
+        EDU_MAP.put("certifierTel", "证明人联系方式");
+    }
+    public boolean saveApply(WorkStaffBasicInfo workStaffBasicInfo,boolean first) {
+        if(workStaffBasicInfo==null|| StringUtils.isBlank(workStaffBasicInfo.getId())){
+            return false;
+        }
+        List<WorkStaffExperience> list = workStaffBasicInfo.getExperienceList();
+        if(list==null||list.size()<=0){
+            return false;
+        }
+        boolean flag = false;
+        User u=userDao.get(workStaffBasicInfo.getUserId());
+        for (WorkStaffExperience entity : list) {
+            entity.setStaffId(workStaffBasicInfo.getId());
+            WorkStaffExperience workStaffExperience=dao.get(entity.getId());
+            if(workStaffExperience==null){
+                entity.setCreateBy(u);
+                entity.setCreateDate(new Date());
+                entity.setUpdateBy(u);
+                entity.setUpdateDate(new Date());
+                dao.insert(entity);
+            }else{
+                this.save(entity);
+            }
+            if(entity!=null&&"1".equals(entity.getDelFlag())){
+                dao.deleteByLogic(entity);
+                continue;
+            }
+            flag =true;
+        }
+        dao.updateFalt(workStaffBasicInfo.getId());
+        return flag;
+    }
+    public void querys(WorkStaffBasicInfo workStaffBasicInfo) {
+        SimpleDateFormat dateFormat1 = new SimpleDateFormat("yyyy-MM-dd");
+        if(workStaffBasicInfo==null|| StringUtils.isBlank(workStaffBasicInfo.getId())){
+            return;
+        }
+        WorkStaffExperience entity = new WorkStaffExperience();
+        entity.setStaffId(workStaffBasicInfo.getId());
+        List<WorkStaffExperience> list=this.findList(entity);
+        List<WorkStaffExperience> newList=Lists.newArrayList();
+        if(list!=null&&list.size()>0){//修改
+            for(WorkStaffExperience workStaffExperience:list){
+                Class<? extends WorkStaffExperience> newClass = workStaffExperience.getClass();
+                Field[] declaredFields = newClass.getDeclaredFields();
+                for (Field field : declaredFields) {
+                    String name = field.getName();
+                    if("company".equals(name)||"dept".equals(name)||"duty".equals(name)||"startDate".equals(name)||"endDate".equals(name)
+                            || "certifier".equals(name)||"certifierTel".equals(name)){
+                        String setMethod = "set"+name.substring(0,1).toUpperCase()+name.substring(1);
+                        String getMethod = "get"+name.substring(0,1).toUpperCase()+name.substring(1);
+                        WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+                        workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+                        workStaffAchivesLog.setModule("工作经历");
+                        workStaffAchivesLog.setSonId(workStaffExperience.getId());
+                        workStaffAchivesLog.setFields(name);
+                        workStaffAchivesLog.setType("修改");
+                        workStaffAchivesLog.setState("1");
+                        List<WorkStaffAchivesLog> logs=workStaffAchivesLogService.findList(workStaffAchivesLog);
+                        try {
+                            Object newInvoke = newClass.getMethod(getMethod).invoke(workStaffExperience);//修改后
+                            if(newInvoke instanceof String){
+                                Method setReadOnly = workStaffExperience.getClass().getMethod(setMethod, String.class);
+                                if(logs!=null&&logs.size()>0){
+                                    setReadOnly.invoke(workStaffExperience,logs.get(0).getNewKey());
+                                }
+                            }
+                            if(newInvoke instanceof Date){//日期
+                                Method setReadOnly = workStaffExperience.getClass().getMethod(setMethod, Date.class);
+                                if(logs!=null&&logs.size()>0){
+                                    Date myDate = dateFormat1.parse(logs.get(0).getNewKey());
+                                    setReadOnly.invoke(workStaffExperience,myDate);
+                                }
+                            }
+                        } catch (NoSuchMethodException e) {
+                            e.printStackTrace();
+                        } catch (IllegalAccessException e) {
+                            e.printStackTrace();
+                        } catch (InvocationTargetException e) {
+                            e.printStackTrace();
+                        } catch (ParseException e) {
+                            e.printStackTrace();
+                        }
+                    }
+                }
+                newList.add(workStaffExperience);
+            }
+        }
+        //新增
+        WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+        workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+        workStaffAchivesLog.setModule("工作经历");
+        workStaffAchivesLog.setType("新增");
+        workStaffAchivesLog.setState("1");
+        List<WorkStaffAchivesLog> sonIds=workStaffAchivesLogService.findSonId(workStaffAchivesLog);
+        if(sonIds!=null&&sonIds.size()>0){
+            for(WorkStaffAchivesLog w:sonIds){
+                workStaffAchivesLog.setSonId(w.getSonId());
+                WorkStaffExperience workStaffExperience = new WorkStaffExperience();
+                workStaffExperience.setId(w.getSonId());
+                workStaffExperience.setDelFlag("0");
+                workStaffExperience.setStaffId(workStaffBasicInfo.getId());
+                Class<? extends WorkStaffExperience> newClass = workStaffExperience.getClass();
+                Field[] declaredFields = newClass.getDeclaredFields();
+                for (Field field : declaredFields) {
+                    String name = field.getName();
+                    if("company".equals(name)||"dept".equals(name)||"duty".equals(name)||"startDate".equals(name)||"endDate".equals(name)
+                            || "certifier".equals(name)||"certifierTel".equals(name)){
+                        String setMethod = "set"+name.substring(0,1).toUpperCase()+name.substring(1);
+                        String getMethod = "get"+name.substring(0,1).toUpperCase()+name.substring(1);
+                        workStaffAchivesLog.setFields(name);
+                        List<WorkStaffAchivesLog> logs=workStaffAchivesLogService.findList(workStaffAchivesLog);
+                        try {
+                            if("startDate".equals(name)||"endDate".equals(name)){//日期
+                                Method setReadOnly = workStaffExperience.getClass().getMethod(setMethod, Date.class);
+                                if(logs!=null&&logs.size()>0){
+                                    Date myDate = dateFormat1.parse(logs.get(0).getNewKey());
+                                    setReadOnly.invoke(workStaffExperience,myDate);
+                                }
+                            }else{
+                                Method setReadOnly = workStaffExperience.getClass().getMethod(setMethod, String.class);
+                                if(logs!=null&&logs.size()>0){
+                                    setReadOnly.invoke(workStaffExperience,logs.get(0).getNewKey());
+                                }
+                            }
+                        } catch (NoSuchMethodException e) {
+                            e.printStackTrace();
+                        } catch (IllegalAccessException e) {
+                            e.printStackTrace();
+                        } catch (InvocationTargetException e) {
+                            e.printStackTrace();
+                        } catch (ParseException e) {
+                            e.printStackTrace();
+                        }
+                    }
+                }
+                newList.add(workStaffExperience);
+            }
+        }
+        //删除
+        WorkStaffAchivesLog delLog=new WorkStaffAchivesLog();
+        delLog.setStaffId(workStaffBasicInfo.getId());
+        delLog.setModule("工作经历");
+        delLog.setType("删除");
+        workStaffAchivesLog.setState("1");
+        List<WorkStaffAchivesLog> dellogs=workStaffAchivesLogService.findList(delLog);
+        if(dellogs!=null&&dellogs.size()>0){
+            for(WorkStaffAchivesLog w:dellogs){
+                newList.remove(dao.get(w.getSonId()));
+            }
+        }
+        workStaffBasicInfo.setExperienceList(newList);
+    }
+    @Transactional(readOnly = false)
+    public void saveEdu(WorkStaffBasicInfo workStaffBasicInfo) {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        List<WorkStaffExperience> experienceList =workStaffBasicInfo.getExperienceList();
+        if(experienceList!=null&&experienceList.size()>0){
+            for(WorkStaffExperience newExperience:experienceList){
+                Class<? extends WorkStaffExperience> newClass = newExperience.getClass();
+                Field[] declaredFields = newClass.getDeclaredFields();
+                if(newExperience.getId()!=null&&!"1".equals(newExperience.getDelFlag())&&!"".equals(newExperience.getId())){
+                    WorkStaffExperience oldExperience=this.get(newExperience.getId());
+                    if(oldExperience!=null){
+                        Class<? extends WorkStaffExperience> oldClass = oldExperience.getClass();
+                        for (Field field : declaredFields) {
+                            String name = field.getName();
+                            if("company".equals(name)||"dept".equals(name)||"duty".equals(name)||"startDate".equals(name)||"endDate".equals(name)
+                                    || "certifier".equals(name)||"certifierTel".equals(name)){
+                                String methodName = "get"+name.substring(0,1).toUpperCase()+name.substring(1);
+                                WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+                                workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+                                workStaffAchivesLog.setModule("工作经历");
+                                workStaffAchivesLog.setSonId(newExperience.getId());
+                                workStaffAchivesLog.setFields(name);
+                                workStaffAchivesLog.setState("1");
+                                try {
+                                    Object newInvoke = newClass.getMethod(methodName).invoke(newExperience);//修改后
+                                    Object oldInvoke = oldClass.getMethod(methodName).invoke(oldExperience);//修改前
+                                    String describes=EDU_MAP.get(name);
+                                    if(newInvoke instanceof String){
+                                        String newValue=newInvoke.toString();
+                                        String oldValue=oldInvoke.toString();
+                                        if(!newValue.equals(oldValue)){
+                                                workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                                        "工作经历",describes,name,
+                                                        oldInvoke.toString(),newInvoke.toString(),
+                                                        oldInvoke.toString(),newInvoke.toString(),newExperience.getId(),"修改");
+
+                                        }
+                                    }
+                                    if(newInvoke instanceof Date){//日期
+                                        String newDate="";
+                                        String oldDate="";
+                                        if(newInvoke!=null){
+                                            newDate=sdf.format(newInvoke);
+                                        }
+                                        if (oldInvoke!=null){
+                                            oldDate=sdf.format(oldInvoke);
+                                        }
+                                        if(!newDate.equals(oldDate)){
+                                            workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                                    "工作经历",describes,name,
+                                                    oldDate,newDate,oldDate,newDate,newExperience.getId(),"修改");
+                                        }
+                                    }
+                                } catch (NoSuchMethodException e) {
+                                    e.printStackTrace();
+                                } catch (IllegalAccessException e) {
+                                    e.printStackTrace();
+                                } catch (InvocationTargetException e) {
+                                    e.printStackTrace();
+                                }
+                            }
+                        }
+
+                    }
+                }else if((newExperience.getId()==null||"".equals(newExperience.getId()))&&"0".equals(newExperience.getDelFlag())){//新增
+                    String newId=IdGen.uuid();
+                    for (Field field : declaredFields) {
+                        String name = field.getName();
+                        if("company".equals(name)||"dept".equals(name)||"duty".equals(name)||"startDate".equals(name)||"endDate".equals(name)
+                                || "certifier".equals(name)||"certifierTel".equals(name)){
+                            String methodName = "get"+name.substring(0,1).toUpperCase()+name.substring(1);
+                            WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+                            workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+                            workStaffAchivesLog.setModule("工作经历");
+                            workStaffAchivesLog.setSonId(newId);
+                            workStaffAchivesLog.setFields(name);
+                            workStaffAchivesLog.setState("1");
+                            try {
+                                Object newInvoke = newClass.getMethod(methodName).invoke(newExperience);//修改后
+                                String describes=EDU_MAP.get(name);
+                                if(newInvoke instanceof String){
+                                    String newValue=newInvoke.toString();
+                                        workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                                "工作经历",describes,name,
+                                                "",newInvoke.toString(),
+                                                "",newInvoke.toString(),newId,"新增");
+
+                                }
+                                if(newInvoke instanceof Date){//日期
+                                    String newDate=sdf.format(newInvoke);
+                                    workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                            "工作经历",describes,name,
+                                            "",newDate,"",newDate,newId,"新增");
+                                };
+                            } catch (NoSuchMethodException e) {
+                                e.printStackTrace();
+                            } catch (IllegalAccessException e) {
+                                e.printStackTrace();
+                            } catch (InvocationTargetException e) {
+                                e.printStackTrace();
+                            }
+                        }
+                    }
+                }else if(newExperience.getId()!=null&&"1".equals(newExperience.getDelFlag())&&!"".equals(newExperience.getId())){//删除
+                    WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+                    workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+                    workStaffAchivesLog.setModule("工作经历");
+                    workStaffAchivesLog.setSonId(newExperience.getId());
+                    workStaffAchivesLog.setType("删除");
+                    workStaffAchivesLog.setState("1");
+                    workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                            "工作经历","","",
+                            "","",
+                            "","",newExperience.getId(),"删除");
+                }
+            }
+        }
+    }
+}

+ 375 - 0
src/main/java/com/jeeplus/modules/workstaff/service/WorkStaffFamilyService.java

@@ -0,0 +1,375 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workstaff.service;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.jeeplus.common.utils.IdGen;
+import com.jeeplus.common.utils.StringUtils;
+import com.jeeplus.modules.sys.dao.UserDao;
+import com.jeeplus.modules.sys.entity.User;
+import com.jeeplus.modules.sys.utils.DictUtils;
+import com.jeeplus.modules.workstaff.entity.WorkStaffBasicInfo;
+import com.jeeplus.modules.workstaff.entity.WorkStaffEducation;
+import com.jeeplus.modules.workstaffachiveslog.entity.WorkStaffAchivesLog;
+import com.jeeplus.modules.workstaffachiveslog.service.WorkStaffAchivesLogService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.jeeplus.common.persistence.Page;
+import com.jeeplus.common.service.CrudService;
+import com.jeeplus.modules.workstaff.entity.WorkStaffFamily;
+import com.jeeplus.modules.workstaff.dao.WorkStaffFamilyDao;
+import org.springframework.web.multipart.MultipartFile;
+
+/**
+ * 家庭情况Service
+ * @author ssrh
+ * @version 2018-07-27
+ */
+@Service
+@Transactional(readOnly = true)
+public class WorkStaffFamilyService extends CrudService<WorkStaffFamilyDao, WorkStaffFamily> {
+    @Autowired
+    private WorkStaffAchivesLogService workStaffAchivesLogService;
+    @Autowired
+    private UserDao userDao;
+	public WorkStaffFamily get(String id) {
+		return super.get(id);
+	}
+	
+	public List<WorkStaffFamily> findList(WorkStaffFamily workStaffFamily) {
+		return super.findList(workStaffFamily);
+	}
+	
+	public Page<WorkStaffFamily> findPage(Page<WorkStaffFamily> page, WorkStaffFamily workStaffFamily) {
+		return super.findPage(page, workStaffFamily);
+	}
+	
+	@Transactional(readOnly = false)
+	public void save(WorkStaffFamily workStaffFamily) {
+		super.save(workStaffFamily);
+	}
+	
+	@Transactional(readOnly = false)
+	public void delete(WorkStaffFamily workStaffFamily) {
+		super.delete(workStaffFamily);
+	}
+
+
+    public boolean save(WorkStaffBasicInfo workStaffBasicInfo,boolean first) {
+        if(workStaffBasicInfo==null|| StringUtils.isBlank(workStaffBasicInfo.getId())){
+            return false;
+        }
+        List<WorkStaffFamily> list = workStaffBasicInfo.getFamilyList();
+        if(list==null||list.size()<=0){
+            return false;
+        }
+        boolean flag = false;
+        for (WorkStaffFamily entity : list) {
+            if(entity!=null&&"1".equals(entity.getDelFlag())&&StringUtils.isBlank(entity.getId())){
+                continue;
+            }
+            if(entity!=null&&"1".equals(entity.getDelFlag())){
+                dao.deleteByLogic(entity);
+                continue;
+            }
+            if (entity!=null){
+                entity.setStaff(workStaffBasicInfo.getId());
+                this.save(entity);
+                if(first){
+                    entity.setId(null);
+                }
+                flag = true;
+            }
+        }
+        return flag;
+    }
+
+    public void query(WorkStaffBasicInfo workStaffBasicInfo) {
+        if(workStaffBasicInfo==null|| StringUtils.isBlank(workStaffBasicInfo.getId())){
+            return;
+        }
+        WorkStaffFamily entity = new WorkStaffFamily();
+        entity.setStaff(workStaffBasicInfo.getId());
+        workStaffBasicInfo.setFamilyList(this.findList(entity));
+    }
+    private static Map<String,String> EDU_MAP = Maps.newHashMap();//教育经历
+
+    static{//教育经历
+        EDU_MAP.put("relation", "与本人的关系");
+        EDU_MAP.put("name", "成员姓名");
+        EDU_MAP.put("idCard", "身份证号码");
+        EDU_MAP.put("gender", "成员性别");
+        EDU_MAP.put("contact", "成员联系方式");
+    }
+    public boolean saveApply(WorkStaffBasicInfo workStaffBasicInfo,boolean first) {
+        if(workStaffBasicInfo==null|| StringUtils.isBlank(workStaffBasicInfo.getId())){
+            return false;
+        }
+        List<WorkStaffFamily> list = workStaffBasicInfo.getFamilyList();
+        if(list==null||list.size()<=0){
+            return false;
+        }
+        boolean flag = false;
+        User u=userDao.get(workStaffBasicInfo.getUserId());
+        for (WorkStaffFamily entity : list) {
+            entity.setStaff(workStaffBasicInfo.getId());
+            WorkStaffFamily workStaffFamily=dao.get(entity.getId());
+            if(workStaffFamily==null){
+                entity.setCreateBy(u);
+                entity.setCreateDate(new Date());
+                entity.setUpdateBy(u);
+                entity.setUpdateDate(new Date());
+                dao.insert(entity);
+            }else{
+                this.save(entity);
+            }
+            if(entity!=null&&"1".equals(entity.getDelFlag())){
+                dao.deleteByLogic(entity);
+                continue;
+            }
+            flag =true;
+        }
+        dao.updateFalt(workStaffBasicInfo.getId());
+        return flag;
+    }
+    public void querys(WorkStaffBasicInfo workStaffBasicInfo) {
+        SimpleDateFormat dateFormat1 = new SimpleDateFormat("yyyy-MM-dd");
+        if(workStaffBasicInfo==null|| StringUtils.isBlank(workStaffBasicInfo.getId())){
+            return;
+        }
+        WorkStaffFamily entity = new WorkStaffFamily();
+        entity.setStaff(workStaffBasicInfo.getId());
+        List<WorkStaffFamily> list=this.findList(entity);
+        List<WorkStaffFamily> newList=Lists.newArrayList();
+        if(list!=null&&list.size()>0){//修改
+            for(WorkStaffFamily workStaffFamily:list){
+                Class<? extends WorkStaffFamily> newClass = workStaffFamily.getClass();
+                Field[] declaredFields = newClass.getDeclaredFields();
+                for (Field field : declaredFields) {
+                    String name = field.getName();
+                    if("relation".equals(name)||"name".equals(name)||"idCard".equals(name)||"gender".equals(name)||"contact".equals(name)
+                           ){
+                        String setMethod = "set"+name.substring(0,1).toUpperCase()+name.substring(1);
+                        String getMethod = "get"+name.substring(0,1).toUpperCase()+name.substring(1);
+                        WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+                        workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+                        workStaffAchivesLog.setModule("家庭情况");
+                        workStaffAchivesLog.setSonId(workStaffFamily.getId());
+                        workStaffAchivesLog.setFields(name);
+                        workStaffAchivesLog.setType("修改");
+                        workStaffAchivesLog.setState("1");
+                        List<WorkStaffAchivesLog> logs=workStaffAchivesLogService.findList(workStaffAchivesLog);
+                        try {
+                            Object newInvoke = newClass.getMethod(getMethod).invoke(workStaffFamily);//修改后
+                            if(newInvoke instanceof String){
+                                Method setReadOnly = workStaffFamily.getClass().getMethod(setMethod, String.class);
+                                if(logs!=null&&logs.size()>0){
+                                    setReadOnly.invoke(workStaffFamily,logs.get(0).getNewKey());
+                                }
+                            }
+                            if(newInvoke instanceof Date){//日期
+                                Method setReadOnly = workStaffFamily.getClass().getMethod(setMethod, Date.class);
+                                if(logs!=null&&logs.size()>0){
+                                    Date myDate = dateFormat1.parse(logs.get(0).getNewKey());
+                                    setReadOnly.invoke(workStaffFamily,myDate);
+                                }
+                            }
+                        } catch (NoSuchMethodException e) {
+                            e.printStackTrace();
+                        } catch (IllegalAccessException e) {
+                            e.printStackTrace();
+                        } catch (InvocationTargetException e) {
+                            e.printStackTrace();
+                        } catch (ParseException e) {
+                            e.printStackTrace();
+                        }
+                    }
+                }
+                newList.add(workStaffFamily);
+            }
+        }
+        //新增
+        WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+        workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+        workStaffAchivesLog.setModule("家庭情况");
+        workStaffAchivesLog.setType("新增");
+        workStaffAchivesLog.setState("1");
+        List<WorkStaffAchivesLog> sonIds=workStaffAchivesLogService.findSonId(workStaffAchivesLog);
+        if(sonIds!=null&&sonIds.size()>0){
+            for(WorkStaffAchivesLog w:sonIds){
+                workStaffAchivesLog.setSonId(w.getSonId());
+                WorkStaffFamily workStaffFamily = new WorkStaffFamily();
+                workStaffFamily.setId(w.getSonId());
+                workStaffFamily.setDelFlag("0");
+                workStaffFamily.setStaff(workStaffBasicInfo.getId());
+                Class<? extends WorkStaffFamily> newClass = workStaffFamily.getClass();
+                Field[] declaredFields = newClass.getDeclaredFields();
+                for (Field field : declaredFields) {
+                    String name = field.getName();
+                    if("relation".equals(name)||"name".equals(name)||"idCard".equals(name)||"gender".equals(name)||"contact".equals(name)
+                            ){
+                        String setMethod = "set"+name.substring(0,1).toUpperCase()+name.substring(1);
+                        String getMethod = "get"+name.substring(0,1).toUpperCase()+name.substring(1);
+                        workStaffAchivesLog.setFields(name);
+                        List<WorkStaffAchivesLog> logs=workStaffAchivesLogService.findList(workStaffAchivesLog);
+                        try {
+                                Method setReadOnly = workStaffFamily.getClass().getMethod(setMethod, String.class);
+                                if(logs!=null&&logs.size()>0){
+                                    setReadOnly.invoke(workStaffFamily,logs.get(0).getNewKey());
+                                }
+                        } catch (NoSuchMethodException e) {
+                            e.printStackTrace();
+                        } catch (IllegalAccessException e) {
+                            e.printStackTrace();
+                        } catch (InvocationTargetException e) {
+                            e.printStackTrace();
+                        }
+                    }
+                }
+                newList.add(workStaffFamily);
+            }
+        }
+        //删除
+        WorkStaffAchivesLog delLog=new WorkStaffAchivesLog();
+        delLog.setStaffId(workStaffBasicInfo.getId());
+        delLog.setModule("家庭情况");
+        delLog.setType("删除");
+        workStaffAchivesLog.setState("1");
+        List<WorkStaffAchivesLog> dellogs=workStaffAchivesLogService.findList(delLog);
+        if(dellogs!=null&&dellogs.size()>0){
+            for(WorkStaffAchivesLog w:dellogs){
+                newList.remove(dao.get(w.getSonId()));
+            }
+        }
+        workStaffBasicInfo.setFamilyList(newList);
+    }
+    @Transactional(readOnly = false)
+    public void saveEdu(WorkStaffBasicInfo workStaffBasicInfo) {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        List<WorkStaffFamily> familyList =workStaffBasicInfo.getFamilyList();
+        if(familyList!=null&&familyList.size()>0){
+            for(WorkStaffFamily newFamily:familyList){
+                Class<? extends WorkStaffFamily> newClass = newFamily.getClass();
+                Field[] declaredFields = newClass.getDeclaredFields();
+                if(newFamily.getId()!=null&&!"1".equals(newFamily.getDelFlag())&&!"".equals(newFamily.getId())){
+                    WorkStaffFamily oldFamily=this.get(newFamily.getId());
+                    if(oldFamily!=null){
+                        Class<? extends WorkStaffFamily> oldClass = oldFamily.getClass();
+                        for (Field field : declaredFields) {
+                            String name = field.getName();
+                            if("relation".equals(name)||"name".equals(name)||"idCard".equals(name)||"gender".equals(name)||"contact".equals(name)
+                                    ){
+                                String methodName = "get"+name.substring(0,1).toUpperCase()+name.substring(1);
+                                WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+                                workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+                                workStaffAchivesLog.setModule("家庭情况");
+                                workStaffAchivesLog.setSonId(newFamily.getId());
+                                workStaffAchivesLog.setFields(name);
+                                workStaffAchivesLog.setState("1");
+                                try {
+                                    Object newInvoke = newClass.getMethod(methodName).invoke(newFamily);//修改后
+                                    Object oldInvoke = oldClass.getMethod(methodName).invoke(oldFamily);//修改前
+                                    String describes=EDU_MAP.get(name);
+                                    if(newInvoke instanceof String){
+                                        String newValue=newInvoke.toString();
+                                        String oldValue=oldInvoke.toString();
+                                        if(!newValue.equals(oldValue)){
+                                                workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                                        "家庭情况",describes,name,
+                                                        oldInvoke.toString(),newInvoke.toString(),
+                                                        oldInvoke.toString(),newInvoke.toString(),newFamily.getId(),"修改");
+                                            }
+                                    }
+                                    if(newInvoke instanceof Date){//日期
+                                        String newDate="";
+                                        String oldDate="";
+                                        if(newInvoke!=null){
+                                            newDate=sdf.format(newInvoke);
+                                        }
+                                        if (oldInvoke!=null){
+                                            oldDate=sdf.format(oldInvoke);
+                                        }
+                                        if(!newDate.equals(oldDate)){
+                                            workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                                    "家庭情况",describes,name,
+                                                    oldDate,newDate,oldDate,newDate,newFamily.getId(),"修改");
+                                        }
+                                    }
+                                } catch (NoSuchMethodException e) {
+                                    e.printStackTrace();
+                                } catch (IllegalAccessException e) {
+                                    e.printStackTrace();
+                                } catch (InvocationTargetException e) {
+                                    e.printStackTrace();
+                                }
+                            }
+                        }
+
+                    }
+                }else if((newFamily.getId()==null||"".equals(newFamily.getId()))&&"0".equals(newFamily.getDelFlag())){//新增
+                    String newId=IdGen.uuid();
+                    for (Field field : declaredFields) {
+                        String name = field.getName();
+                        if("relation".equals(name)||"name".equals(name)||"idCard".equals(name)||"gender".equals(name)||"contact".equals(name)
+                                ){
+                            String methodName = "get"+name.substring(0,1).toUpperCase()+name.substring(1);
+                            WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+                            workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+                            workStaffAchivesLog.setModule("家庭情况");
+                            workStaffAchivesLog.setSonId(newId);
+                            workStaffAchivesLog.setFields(name);
+                            workStaffAchivesLog.setState("1");
+                            try {
+                                Object newInvoke = newClass.getMethod(methodName).invoke(newFamily);//修改后
+                                String describes=EDU_MAP.get(name);
+                                if(newInvoke instanceof String){
+                                    String newValue=newInvoke.toString();
+                                        workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                                "家庭情况",describes,name,
+                                                "",newInvoke.toString(),
+                                                "",newInvoke.toString(),newId,"新增");
+                                }
+                                if(newInvoke instanceof Date){//日期
+                                    String newDate=sdf.format(newInvoke);
+                                    workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                            "家庭情况",describes,name,
+                                            "",newDate,"",newDate,newId,"新增");
+                                };
+                            } catch (NoSuchMethodException e) {
+                                e.printStackTrace();
+                            } catch (IllegalAccessException e) {
+                                e.printStackTrace();
+                            } catch (InvocationTargetException e) {
+                                e.printStackTrace();
+                            }
+                        }
+                    }
+                }else if(newFamily.getId()!=null&&"1".equals(newFamily.getDelFlag())&&!"".equals(newFamily.getId())){//删除
+                    WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+                    workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+                    workStaffAchivesLog.setModule("家庭情况");
+                    workStaffAchivesLog.setSonId(newFamily.getId());
+                    workStaffAchivesLog.setType("删除");
+                    workStaffAchivesLog.setState("1");
+                    workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                            "家庭情况","","",
+                            "","",
+                            "","",newFamily.getId(),"删除");
+                }
+            }
+        }
+    }
+}

+ 470 - 0
src/main/java/com/jeeplus/modules/workstaff/service/WorkStaffLanguagesService.java

@@ -0,0 +1,470 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workstaff.service;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.jeeplus.common.config.Global;
+import com.jeeplus.common.oss.OSSClientUtil;
+import com.jeeplus.common.utils.DateUtils;
+import com.jeeplus.common.utils.IdGen;
+import com.jeeplus.common.utils.StringUtils;
+import com.jeeplus.modules.sys.dao.UserDao;
+import com.jeeplus.modules.sys.entity.User;
+import com.jeeplus.modules.sys.utils.DictUtils;
+import com.jeeplus.modules.workstaff.entity.WorkStaffBasicInfo;
+import com.jeeplus.modules.workstaff.entity.WorkStaffEducation;
+import com.jeeplus.modules.workstaffachiveslog.entity.WorkStaffAchivesLog;
+import com.jeeplus.modules.workstaffachiveslog.service.WorkStaffAchivesLogService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.jeeplus.common.persistence.Page;
+import com.jeeplus.common.service.CrudService;
+import com.jeeplus.modules.workstaff.entity.WorkStaffLanguages;
+import com.jeeplus.modules.workstaff.dao.WorkStaffLanguagesDao;
+import org.springframework.web.multipart.MultipartFile;
+
+/**
+ * 外语信息Service
+ * @author ssrh
+ * @version 2018-07-27
+ */
+@Service
+@Transactional(readOnly = true)
+public class WorkStaffLanguagesService extends CrudService<WorkStaffLanguagesDao, WorkStaffLanguages> {
+    @Autowired
+    private WorkStaffAchivesLogService workStaffAchivesLogService;
+    @Autowired
+    private UserDao userDao;
+	public WorkStaffLanguages get(String id) {
+		return super.get(id);
+	}
+	
+	public List<WorkStaffLanguages> findList(WorkStaffLanguages workStaffLanguages) {
+		return super.findList(workStaffLanguages);
+	}
+	
+	public Page<WorkStaffLanguages> findPage(Page<WorkStaffLanguages> page, WorkStaffLanguages workStaffLanguages) {
+		return super.findPage(page, workStaffLanguages);
+	}
+	
+	@Transactional(readOnly = false)
+	public void save(WorkStaffLanguages workStaffLanguages) {
+		super.save(workStaffLanguages);
+	}
+	
+	@Transactional(readOnly = false)
+	public void delete(WorkStaffLanguages workStaffLanguages) {
+		super.delete(workStaffLanguages);
+	}
+
+
+    public boolean save(WorkStaffBasicInfo workStaffBasicInfo,boolean first) {
+        if(workStaffBasicInfo==null|| StringUtils.isBlank(workStaffBasicInfo.getId())){
+            return false;
+        }
+        List<WorkStaffLanguages> list = workStaffBasicInfo.getLanguageList();
+        if(list==null||list.size()<=0){
+            return false;
+        }
+        boolean flag=false;
+        for (WorkStaffLanguages entity : list) {
+            if(entity!=null&&"1".equals(entity.getDelFlag())&&StringUtils.isBlank(entity.getId())){
+                continue;
+            }
+            if(entity!=null&&"1".equals(entity.getDelFlag())){
+                dao.deleteByLogic(entity);
+                continue;
+            }
+            if (entity!=null){
+                if(entity.getFile()!=null&&!entity.getFile().isEmpty()&&entity.getFile().getSize()>0){
+                    MultipartFile file = entity.getFile();
+                    entity.setFileName(file.getOriginalFilename());
+                    entity.setFilePath(this.uploadFile(file,entity.getFilePath()));
+                }
+                entity.setStaffId(workStaffBasicInfo.getId());
+                this.save(entity);
+                if(first){
+                    entity.setId(null);
+                    entity.setFilePath("");
+                }
+                flag = true;
+            }
+        }
+        return flag;
+    }
+
+    public String uploadFile(MultipartFile file, String filePath) {
+        if (file != null && !file.isEmpty() &&file.getSize()>0) {
+            String key = "";
+            if (StringUtils.isNotBlank(filePath)) {
+                String aliyunUrl = Global.getAliyunUrl();
+                String aliDownloadUrl = Global.getAliDownloadUrl();
+                String cons = "";
+                if (filePath.contains(aliyunUrl)) {
+                    cons = aliyunUrl;
+                } else if (filePath.contains("http://gangwan-app.oss-cn-hangzhou.aliyuncs.com")) {
+                    cons = "http://gangwan-app.oss-cn-hangzhou.aliyuncs.com";
+                } else {
+                    cons = aliDownloadUrl;
+                }
+                String[] arr = filePath.split(cons + "/");
+                key = arr[1];
+            }
+            try {
+                OSSClientUtil ossUtil1 = new OSSClientUtil();
+                if (StringUtils.isNotBlank(key)) {
+                    ossUtil1.deleteSingleObject(key);
+                }
+            }catch (Exception e){
+                logger.error("oss删除文件失败!");
+            }
+            try {
+                OSSClientUtil ossUtil = new OSSClientUtil();
+                String path = Global.getStaffBasicFilePath()+ DateUtils.formatDate(new Date(), null)+"/";
+                String newName = System.currentTimeMillis()+"-"+file.getOriginalFilename();
+                ossUtil.uploadFile2OSS(file.getInputStream(),path,newName);
+                return  Global.getAliDownloadUrl() + "/" + path + newName;
+            } catch (Exception e) {
+                logger.error("oss上传文件失败!");
+            }
+        }
+        return filePath;
+    }
+
+    public void query(WorkStaffBasicInfo workStaffBasicInfo) {
+        if(workStaffBasicInfo==null|| StringUtils.isBlank(workStaffBasicInfo.getId())){
+            return;
+        }
+        WorkStaffLanguages entity = new WorkStaffLanguages();
+        entity.setStaffId(workStaffBasicInfo.getId());
+        workStaffBasicInfo.setLanguageList(this.findList(entity));
+    }
+
+    private static Map<String,String> EDU_MAP = Maps.newHashMap();//教育经历
+
+    static{//教育经历
+        EDU_MAP.put("language", "语种");
+        EDU_MAP.put("proficiency", "熟练程度");
+        EDU_MAP.put("certificate", "证书名称");
+        EDU_MAP.put("certifDate", "获证日期");
+        EDU_MAP.put("filePath", "文件");
+        EDU_MAP.put("fileName", "文件名");
+    }
+    public boolean saveApply(WorkStaffBasicInfo workStaffBasicInfo,boolean first) {
+        if(workStaffBasicInfo==null|| StringUtils.isBlank(workStaffBasicInfo.getId())){
+            return false;
+        }
+        List<WorkStaffLanguages> list = workStaffBasicInfo.getLanguageList();
+        if(list==null||list.size()<=0){
+            return false;
+        }
+        boolean flag = false;
+        User u=userDao.get(workStaffBasicInfo.getUserId());
+        for (WorkStaffLanguages entity : list) {
+            entity.setStaffId(workStaffBasicInfo.getId());
+            WorkStaffLanguages workStaffLanguages=dao.get(entity.getId());
+            if(workStaffLanguages==null){
+                entity.setCreateBy(u);
+                entity.setCreateDate(new Date());
+                entity.setUpdateBy(u);
+                entity.setUpdateDate(new Date());
+                dao.insert(entity);
+            }else{
+                this.save(entity);
+            }
+            if(entity!=null&&"1".equals(entity.getDelFlag())){
+                dao.deleteByLogic(entity);
+                continue;
+            }
+            flag =true;
+        }
+        dao.updateFalt(workStaffBasicInfo.getId());
+        return flag;
+    }
+    public void querys(WorkStaffBasicInfo workStaffBasicInfo) {
+        SimpleDateFormat dateFormat1 = new SimpleDateFormat("yyyy-MM-dd");
+        if(workStaffBasicInfo==null|| StringUtils.isBlank(workStaffBasicInfo.getId())){
+            return;
+        }
+        WorkStaffLanguages entity = new WorkStaffLanguages();
+        entity.setStaffId(workStaffBasicInfo.getId());
+        List<WorkStaffLanguages> list=this.findList(entity);
+        List<WorkStaffLanguages> newList=Lists.newArrayList();
+        if(list!=null&&list.size()>0){//修改
+            for(WorkStaffLanguages workStaffLanguages:list){
+                Class<? extends WorkStaffLanguages> newClass = workStaffLanguages.getClass();
+                Field[] declaredFields = newClass.getDeclaredFields();
+                for (Field field : declaredFields) {
+                    String name = field.getName();
+                    if("language".equals(name)||"proficiency".equals(name)||"certificate".equals(name)||"certifDate".equals(name)||"filePath".equals(name)
+                            || "fileName".equals(name)){
+                        String setMethod = "set"+name.substring(0,1).toUpperCase()+name.substring(1);
+                        String getMethod = "get"+name.substring(0,1).toUpperCase()+name.substring(1);
+                        WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+                        workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+                        workStaffAchivesLog.setModule("外语语种");
+                        workStaffAchivesLog.setSonId(workStaffLanguages.getId());
+                        workStaffAchivesLog.setFields(name);
+                        workStaffAchivesLog.setType("修改");
+                        workStaffAchivesLog.setState("1");
+                        List<WorkStaffAchivesLog> logs=workStaffAchivesLogService.findList(workStaffAchivesLog);
+                        try {
+                            Object newInvoke = newClass.getMethod(getMethod).invoke(workStaffLanguages);//修改后
+                            if(newInvoke instanceof String){
+                                Method setReadOnly = workStaffLanguages.getClass().getMethod(setMethod, String.class);
+                                if(logs!=null&&logs.size()>0){
+                                    setReadOnly.invoke(workStaffLanguages,logs.get(0).getNewKey());
+                                }
+                            }
+                            if(newInvoke instanceof Date){//日期
+                                Method setReadOnly = workStaffLanguages.getClass().getMethod(setMethod, Date.class);
+                                if(logs!=null&&logs.size()>0){
+                                    Date myDate = dateFormat1.parse(logs.get(0).getNewKey());
+                                    setReadOnly.invoke(workStaffLanguages,myDate);
+                                }
+                            }
+                        } catch (NoSuchMethodException e) {
+                            e.printStackTrace();
+                        } catch (IllegalAccessException e) {
+                            e.printStackTrace();
+                        } catch (InvocationTargetException e) {
+                            e.printStackTrace();
+                        } catch (ParseException e) {
+                            e.printStackTrace();
+                        }
+                    }
+                }
+                newList.add(workStaffLanguages);
+            }
+        }
+        //新增
+        WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+        workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+        workStaffAchivesLog.setModule("外语语种");
+        workStaffAchivesLog.setType("新增");
+        workStaffAchivesLog.setState("1");
+        List<WorkStaffAchivesLog> sonIds=workStaffAchivesLogService.findSonId(workStaffAchivesLog);
+        if(sonIds!=null&&sonIds.size()>0){
+            for(WorkStaffAchivesLog w:sonIds){
+                workStaffAchivesLog.setSonId(w.getSonId());
+                WorkStaffLanguages workStaffLanguages = new WorkStaffLanguages();
+                workStaffLanguages.setId(w.getSonId());
+                workStaffLanguages.setDelFlag("0");
+                workStaffLanguages.setStaffId(workStaffBasicInfo.getId());
+                Class<? extends WorkStaffLanguages> newClass = workStaffLanguages.getClass();
+                Field[] declaredFields = newClass.getDeclaredFields();
+                for (Field field : declaredFields) {
+                    String name = field.getName();
+                    if("language".equals(name)||"proficiency".equals(name)||"certificate".equals(name)||"certifDate".equals(name)||"filePath".equals(name)
+                            || "fileName".equals(name)){
+                        String setMethod = "set"+name.substring(0,1).toUpperCase()+name.substring(1);
+                        String getMethod = "get"+name.substring(0,1).toUpperCase()+name.substring(1);
+                        workStaffAchivesLog.setFields(name);
+                        List<WorkStaffAchivesLog> logs=workStaffAchivesLogService.findList(workStaffAchivesLog);
+                        try {
+                            if("certifDate".equals(name)){//日期
+                                Method setReadOnly = workStaffLanguages.getClass().getMethod(setMethod, Date.class);
+                                if(logs!=null&&logs.size()>0){
+                                    Date myDate = dateFormat1.parse(logs.get(0).getNewKey());
+                                    setReadOnly.invoke(workStaffLanguages,myDate);
+                                }
+                            }else{
+                                Method setReadOnly = workStaffLanguages.getClass().getMethod(setMethod, String.class);
+                                if(logs!=null&&logs.size()>0){
+                                    setReadOnly.invoke(workStaffLanguages,logs.get(0).getNewKey());
+                                }
+                            }
+                        } catch (NoSuchMethodException e) {
+                            e.printStackTrace();
+                        } catch (IllegalAccessException e) {
+                            e.printStackTrace();
+                        } catch (InvocationTargetException e) {
+                            e.printStackTrace();
+                        } catch (ParseException e) {
+                            e.printStackTrace();
+                        }
+                    }
+                }
+                newList.add(workStaffLanguages);
+            }
+        }
+        //删除
+        WorkStaffAchivesLog delLog=new WorkStaffAchivesLog();
+        delLog.setStaffId(workStaffBasicInfo.getId());
+        delLog.setModule("外语语种");
+        delLog.setType("删除");
+        workStaffAchivesLog.setState("1");
+        List<WorkStaffAchivesLog> dellogs=workStaffAchivesLogService.findList(delLog);
+        if(dellogs!=null&&dellogs.size()>0){
+            for(WorkStaffAchivesLog w:dellogs){
+                newList.remove(dao.get(w.getSonId()));
+            }
+        }
+        workStaffBasicInfo.setLanguageList(newList);
+    }
+    @Transactional(readOnly = false)
+    public void saveEdu(WorkStaffBasicInfo workStaffBasicInfo) {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        List<WorkStaffLanguages> languagesList =workStaffBasicInfo.getLanguageList();
+        if(languagesList!=null&&languagesList.size()>0){
+            for(WorkStaffLanguages newLanguages:languagesList){
+                Class<? extends WorkStaffLanguages> newClass = newLanguages.getClass();
+                Field[] declaredFields = newClass.getDeclaredFields();
+                if(newLanguages.getId()!=null&&!"1".equals(newLanguages.getDelFlag())&&!"".equals(newLanguages.getId())){
+                    if(newLanguages.getFile()!=null&&!newLanguages.getFile().isEmpty()&&newLanguages.getFile().getSize()>0){
+                        MultipartFile file = newLanguages.getFile();
+                        newLanguages.setFilePath(this.uploadFile(file,newLanguages.getFilePath()));
+                    }
+                    WorkStaffLanguages oldLanguages=this.get(newLanguages.getId());
+                    if(oldLanguages!=null){
+                        Class<? extends WorkStaffLanguages> oldClass = oldLanguages.getClass();
+                        for (Field field : declaredFields) {
+                            String name = field.getName();
+                            if("language".equals(name)||"proficiency".equals(name)||"certificate".equals(name)||"certifDate".equals(name)||"filePath".equals(name)
+                                    || "fileName".equals(name)){
+                                String methodName = "get"+name.substring(0,1).toUpperCase()+name.substring(1);
+                                WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+                                workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+                                workStaffAchivesLog.setModule("外语语种");
+                                workStaffAchivesLog.setSonId(newLanguages.getId());
+                                workStaffAchivesLog.setFields(name);
+                                workStaffAchivesLog.setState("1");
+                                try {
+                                    Object newInvoke = newClass.getMethod(methodName).invoke(newLanguages);//修改后
+                                    Object oldInvoke = oldClass.getMethod(methodName).invoke(oldLanguages);//修改前
+                                    String describes=EDU_MAP.get(name);
+                                    if(newInvoke instanceof String){
+                                        String newValue=newInvoke.toString();
+                                        String oldValue=oldInvoke.toString();
+                                        if(!newValue.equals(oldValue)){
+                                            if("language".equals(name)){
+                                                workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                                        "外语语种",describes,name,
+                                                        DictUtils.getMainDictLabel(oldValue,"language",""),
+                                                        DictUtils.getMainDictLabel(newValue,"language",""),
+                                                        oldValue,newValue,newLanguages.getId(),"修改");
+                                            }else if("proficiency".equals(name)){
+                                                workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                                        "外语语种",describes,name,
+                                                        DictUtils.getDictLabel(oldValue,"proficiency",""),
+                                                        DictUtils.getDictLabel(newValue,"proficiency",""),
+                                                        oldValue,newValue,newLanguages.getId(),"修改");
+                                            }else{
+                                                workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                                        "外语语种",describes,name,
+                                                        oldInvoke.toString(),newInvoke.toString(),
+                                                        oldInvoke.toString(),newInvoke.toString(),newLanguages.getId(),"修改");
+                                            }
+                                        }
+                                    }
+                                    if(newInvoke instanceof Date){//日期
+                                        String newDate="";
+                                        String oldDate="";
+                                        if(newInvoke!=null){
+                                            newDate=sdf.format(newInvoke);
+                                        }
+                                        if (oldInvoke!=null){
+                                            oldDate=sdf.format(oldInvoke);
+                                        }
+                                        if(!newDate.equals(oldDate)){
+                                            workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                                    "外语语种",describes,name,
+                                                    oldDate,newDate,oldDate,newDate,newLanguages.getId(),"修改");
+                                        }
+                                    }
+                                } catch (NoSuchMethodException e) {
+                                    e.printStackTrace();
+                                } catch (IllegalAccessException e) {
+                                    e.printStackTrace();
+                                } catch (InvocationTargetException e) {
+                                    e.printStackTrace();
+                                }
+                            }
+                        }
+
+                    }
+                }else if((newLanguages.getId()==null||"".equals(newLanguages.getId()))&&"0".equals(newLanguages.getDelFlag())){//新增
+                    if(newLanguages.getFile()!=null&&!newLanguages.getFile().isEmpty()&&newLanguages.getFile().getSize()>0){
+                        MultipartFile file = newLanguages.getFile();
+                        newLanguages.setFilePath(this.uploadFile(file,newLanguages.getFilePath()));
+                    }
+                    String newId=IdGen.uuid();
+                    for (Field field : declaredFields) {
+                        String name = field.getName();
+                        if("language".equals(name)||"proficiency".equals(name)||"certificate".equals(name)||"certifDate".equals(name)||"filePath".equals(name)
+                                || "fileName".equals(name)){
+                            String methodName = "get"+name.substring(0,1).toUpperCase()+name.substring(1);
+                            WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+                            workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+                            workStaffAchivesLog.setModule("外语语种");
+                            workStaffAchivesLog.setSonId(newId);
+                            workStaffAchivesLog.setFields(name);
+                            workStaffAchivesLog.setState("1");
+                            try {
+                                Object newInvoke = newClass.getMethod(methodName).invoke(newLanguages);//修改后
+                                String describes=EDU_MAP.get(name);
+                                if(newInvoke instanceof String){
+                                    String newValue=newInvoke.toString();
+                                    if("language".equals(name)){
+                                        workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                                "外语语种",describes,name,
+                                                "",
+                                                DictUtils.getMainDictLabel(newValue,"language",""),
+                                                "",newValue,newId,"新增");
+                                    }else if("proficiency".equals(name)){
+                                        workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                                "外语语种",describes,name,
+                                                "",
+                                                DictUtils.getDictLabel(newValue,"proficiency",""),
+                                                "",newValue,newId,"新增");
+                                    }else{
+                                        workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                                "外语语种",describes,name,
+                                                "",newInvoke.toString(),
+                                                "",newInvoke.toString(),newId,"新增");
+                                    }
+                                }
+                                if(newInvoke instanceof Date){//日期
+                                    String newDate=sdf.format(newInvoke);
+                                    workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                            "外语语种",describes,name,
+                                            "",newDate,"",newDate,newId,"新增");
+                                };
+                            } catch (NoSuchMethodException e) {
+                                e.printStackTrace();
+                            } catch (IllegalAccessException e) {
+                                e.printStackTrace();
+                            } catch (InvocationTargetException e) {
+                                e.printStackTrace();
+                            }
+                        }
+                    }
+                }else if(newLanguages.getId()!=null&&"1".equals(newLanguages.getDelFlag())&&!"".equals(newLanguages.getId())){//删除
+                    WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+                    workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+                    workStaffAchivesLog.setModule("外语语种");
+                    workStaffAchivesLog.setSonId(newLanguages.getId());
+                    workStaffAchivesLog.setType("删除");
+                    workStaffAchivesLog.setState("1");
+                    workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                            "外语语种","","",
+                            "","",
+                            "","",newLanguages.getId(),"删除");
+                }
+            }
+        }
+    }
+}

+ 443 - 0
src/main/java/com/jeeplus/modules/workstaff/service/WorkStaffRecordService.java

@@ -0,0 +1,443 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workstaff.service;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.jeeplus.common.config.Global;
+import com.jeeplus.common.oss.OSSClientUtil;
+import com.jeeplus.common.utils.DateUtils;
+import com.jeeplus.common.utils.IdGen;
+import com.jeeplus.common.utils.StringUtils;
+import com.jeeplus.modules.sys.dao.UserDao;
+import com.jeeplus.modules.sys.entity.User;
+import com.jeeplus.modules.sys.utils.DictUtils;
+import com.jeeplus.modules.workstaff.entity.WorkStaffBasicInfo;
+import com.jeeplus.modules.workstaff.entity.WorkStaffLanguages;
+import com.jeeplus.modules.workstaffachiveslog.entity.WorkStaffAchivesLog;
+import com.jeeplus.modules.workstaffachiveslog.service.WorkStaffAchivesLogService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.jeeplus.common.persistence.Page;
+import com.jeeplus.common.service.CrudService;
+import com.jeeplus.modules.workstaff.entity.WorkStaffRecord;
+import com.jeeplus.modules.workstaff.dao.WorkStaffRecordDao;
+import org.springframework.web.multipart.MultipartFile;
+
+/**
+ * 电子档案Service
+ * @author ssrh
+ * @version 2018-07-27
+ */
+@Service
+@Transactional(readOnly = true)
+public class WorkStaffRecordService extends CrudService<WorkStaffRecordDao, WorkStaffRecord> {
+    @Autowired
+    private WorkStaffAchivesLogService workStaffAchivesLogService;
+    @Autowired
+    private UserDao userDao;
+	public WorkStaffRecord get(String id) {
+		return super.get(id);
+	}
+	
+	public List<WorkStaffRecord> findList(WorkStaffRecord workStaffRecord) {
+		return super.findList(workStaffRecord);
+	}
+	
+	public Page<WorkStaffRecord> findPage(Page<WorkStaffRecord> page, WorkStaffRecord workStaffRecord) {
+		return super.findPage(page, workStaffRecord);
+	}
+	
+	@Transactional(readOnly = false)
+	public void save(WorkStaffRecord workStaffRecord) {
+		super.save(workStaffRecord);
+	}
+	
+	@Transactional(readOnly = false)
+	public void delete(WorkStaffRecord workStaffRecord) {
+		super.delete(workStaffRecord);
+	}
+
+
+    public boolean save(WorkStaffBasicInfo workStaffBasicInfo,boolean first) {
+        if(workStaffBasicInfo==null|| StringUtils.isBlank(workStaffBasicInfo.getId())){
+            return false;
+        }
+        List<WorkStaffRecord> list = workStaffBasicInfo.getRecordList();
+        if(list==null||list.size()<=0){
+            return false;
+        }
+        boolean flag=false;
+        for (WorkStaffRecord entity : list) {
+            if(entity!=null&&"1".equals(entity.getDelFlag())&&StringUtils.isBlank(entity.getId())){
+                continue;
+            }
+            if(entity!=null&&"1".equals(entity.getDelFlag())){
+                dao.deleteByLogic(entity);
+                continue;
+            }
+            if (entity!=null){
+                if(entity.getFile()!=null&&!entity.getFile().isEmpty()&&entity.getFile().getSize()>0){
+                    MultipartFile file = entity.getFile();
+                    entity.setFileName(file.getOriginalFilename());
+                    entity.setFilePath(this.uploadFile(file,entity.getFilePath()));
+                }
+                entity.setStaff(workStaffBasicInfo.getId());
+                this.save(entity);
+                if(first){
+                    entity.setId(null);
+                    entity.setFilePath("");
+                }
+                flag =true;
+            }
+        }
+        return flag;
+    }
+
+    public String uploadFile(MultipartFile file, String filePath) {
+        if (file != null && !file.isEmpty() &&file.getSize()>0) {
+            String key = "";
+            if (StringUtils.isNotBlank(filePath)) {
+                String aliyunUrl = Global.getAliyunUrl();
+                String aliDownloadUrl = Global.getAliDownloadUrl();
+                String cons = "";
+                if (filePath.contains(aliyunUrl)) {
+                    cons = aliyunUrl;
+                } else if (filePath.contains("http://gangwan-app.oss-cn-hangzhou.aliyuncs.com")) {
+                    cons = "http://gangwan-app.oss-cn-hangzhou.aliyuncs.com";
+                } else {
+                    cons = aliDownloadUrl;
+                }
+                String[] arr = filePath.split(cons + "/");
+                key = arr[1];
+            }
+            try {
+                OSSClientUtil ossUtil1 = new OSSClientUtil();
+                if (StringUtils.isNotBlank(key)) {
+                    ossUtil1.deleteSingleObject(key);
+                }
+            }catch (Exception e){
+                logger.error("oss删除文件失败!");
+
+            }
+            OSSClientUtil ossUtil = new OSSClientUtil();
+            try {
+                String path = Global.getStaffBasicFilePath()+ DateUtils.formatDate(new Date(),null)+"/";
+                String newName = System.currentTimeMillis()+"-"+file.getOriginalFilename();
+                ossUtil.uploadFile2OSS(file.getInputStream(),path,newName);
+                return  Global.getAliDownloadUrl() + "/" + path + newName;
+            } catch (Exception e) {
+                logger.error("oss上传文件失败!");
+            }
+        }
+        return filePath;
+    }
+
+    public void query(WorkStaffBasicInfo workStaffBasicInfo) {
+        if(workStaffBasicInfo==null|| StringUtils.isBlank(workStaffBasicInfo.getId())){
+            return;
+        }
+        WorkStaffRecord entity = new WorkStaffRecord();
+        entity.setStaff(workStaffBasicInfo.getId());
+        workStaffBasicInfo.setRecordList(this.findList(entity));
+    }
+    private static Map<String,String> EDU_MAP = Maps.newHashMap();//教育经历
+
+    static{//教育经历
+        EDU_MAP.put("name", "档案名称");
+        EDU_MAP.put("num", "编号");
+        EDU_MAP.put("filePath", "文件");
+        EDU_MAP.put("status", "验证");
+        EDU_MAP.put("fileName", "文件名");
+    }
+    public boolean saveApply(WorkStaffBasicInfo workStaffBasicInfo,boolean first) {
+        if(workStaffBasicInfo==null|| StringUtils.isBlank(workStaffBasicInfo.getId())){
+            return false;
+        }
+        List<WorkStaffRecord> list = workStaffBasicInfo.getRecordList();
+        if(list==null||list.size()<=0){
+            return false;
+        }
+        boolean flag = false;
+        User u=userDao.get(workStaffBasicInfo.getUserId());
+        for (WorkStaffRecord entity : list) {
+            entity.setStaff(workStaffBasicInfo.getId());
+            WorkStaffRecord workStaffRecord=dao.get(entity.getId());
+            if(workStaffRecord==null){
+                entity.setCreateBy(u);
+                entity.setCreateDate(new Date());
+                entity.setUpdateBy(u);
+                entity.setUpdateDate(new Date());
+                dao.insert(entity);
+            }else{
+                this.save(entity);
+            }
+            if(entity!=null&&"1".equals(entity.getDelFlag())){
+                dao.deleteByLogic(entity);
+                continue;
+            }
+            flag =true;
+        }
+        dao.updateFalt(workStaffBasicInfo.getId());
+        return flag;
+    }
+    public void querys(WorkStaffBasicInfo workStaffBasicInfo) {
+        SimpleDateFormat dateFormat1 = new SimpleDateFormat("yyyy-MM-dd");
+        if(workStaffBasicInfo==null|| StringUtils.isBlank(workStaffBasicInfo.getId())){
+            return;
+        }
+        WorkStaffRecord entity = new WorkStaffRecord();
+        entity.setStaff(workStaffBasicInfo.getId());
+        List<WorkStaffRecord> list=this.findList(entity);
+        List<WorkStaffRecord> newList=Lists.newArrayList();
+        if(list!=null&&list.size()>0){//修改
+            for(WorkStaffRecord workStaffRecord:list){
+                Class<? extends WorkStaffRecord> newClass = workStaffRecord.getClass();
+                Field[] declaredFields = newClass.getDeclaredFields();
+                for (Field field : declaredFields) {
+                    String name = field.getName();
+                    if("name".equals(name)||"num".equals(name)||"filePath".equals(name)||"status".equals(name)||"fileName".equals(name)){
+                        String setMethod = "set"+name.substring(0,1).toUpperCase()+name.substring(1);
+                        String getMethod = "get"+name.substring(0,1).toUpperCase()+name.substring(1);
+                        WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+                        workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+                        workStaffAchivesLog.setModule("电子档案");
+                        workStaffAchivesLog.setSonId(workStaffRecord.getId());
+                        workStaffAchivesLog.setFields(name);
+                        workStaffAchivesLog.setType("修改");
+                        workStaffAchivesLog.setState("1");
+                        List<WorkStaffAchivesLog> logs=workStaffAchivesLogService.findList(workStaffAchivesLog);
+                        try {
+                            Object newInvoke = newClass.getMethod(getMethod).invoke(workStaffRecord);//修改后
+                            if(newInvoke instanceof String){
+                                Method setReadOnly = workStaffRecord.getClass().getMethod(setMethod, String.class);
+                                if(logs!=null&&logs.size()>0){
+                                    setReadOnly.invoke(workStaffRecord,logs.get(0).getNewKey());
+                                }
+                            }
+                            if(newInvoke instanceof Date){//日期
+                                Method setReadOnly = workStaffRecord.getClass().getMethod(setMethod, Date.class);
+                                if(logs!=null&&logs.size()>0){
+                                    Date myDate = dateFormat1.parse(logs.get(0).getNewKey());
+                                    setReadOnly.invoke(workStaffRecord,myDate);
+                                }
+                            }
+                        } catch (NoSuchMethodException e) {
+                            e.printStackTrace();
+                        } catch (IllegalAccessException e) {
+                            e.printStackTrace();
+                        } catch (InvocationTargetException e) {
+                            e.printStackTrace();
+                        } catch (ParseException e) {
+                            e.printStackTrace();
+                        }
+                    }
+                }
+                newList.add(workStaffRecord);
+            }
+        }
+        //新增
+        WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+        workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+        workStaffAchivesLog.setModule("电子档案");
+        workStaffAchivesLog.setType("新增");
+        workStaffAchivesLog.setState("1");
+        List<WorkStaffAchivesLog> sonIds=workStaffAchivesLogService.findSonId(workStaffAchivesLog);
+        if(sonIds!=null&&sonIds.size()>0){
+            for(WorkStaffAchivesLog w:sonIds){
+                workStaffAchivesLog.setSonId(w.getSonId());
+                WorkStaffRecord workStaffRecord = new WorkStaffRecord();
+                workStaffRecord.setId(w.getSonId());
+                workStaffRecord.setDelFlag("0");
+                workStaffRecord.setStaff(workStaffBasicInfo.getId());
+                Class<? extends WorkStaffRecord> newClass = workStaffRecord.getClass();
+                Field[] declaredFields = newClass.getDeclaredFields();
+                for (Field field : declaredFields) {
+                    String name = field.getName();
+                    if("name".equals(name)||"num".equals(name)||"filePath".equals(name)||"status".equals(name)||"fileName".equals(name)){
+                        String setMethod = "set"+name.substring(0,1).toUpperCase()+name.substring(1);
+                        String getMethod = "get"+name.substring(0,1).toUpperCase()+name.substring(1);
+                        workStaffAchivesLog.setFields(name);
+                        List<WorkStaffAchivesLog> logs=workStaffAchivesLogService.findList(workStaffAchivesLog);
+                        try {
+                                Method setReadOnly = workStaffRecord.getClass().getMethod(setMethod, String.class);
+                                if(logs!=null&&logs.size()>0){
+                                    setReadOnly.invoke(workStaffRecord,logs.get(0).getNewKey());
+                                }
+                        } catch (NoSuchMethodException e) {
+                            e.printStackTrace();
+                        } catch (IllegalAccessException e) {
+                            e.printStackTrace();
+                        } catch (InvocationTargetException e) {
+                            e.printStackTrace();
+                        }
+                    }
+                }
+                newList.add(workStaffRecord);
+            }
+        }
+        //删除
+        WorkStaffAchivesLog delLog=new WorkStaffAchivesLog();
+        delLog.setStaffId(workStaffBasicInfo.getId());
+        delLog.setModule("电子档案");
+        delLog.setType("删除");
+        workStaffAchivesLog.setState("1");
+        List<WorkStaffAchivesLog> dellogs=workStaffAchivesLogService.findList(delLog);
+        if(dellogs!=null&&dellogs.size()>0){
+            for(WorkStaffAchivesLog w:dellogs){
+                newList.remove(dao.get(w.getSonId()));
+            }
+        }
+        workStaffBasicInfo.setRecordList(newList);
+    }
+    @Transactional(readOnly = false)
+    public void saveEdu(WorkStaffBasicInfo workStaffBasicInfo) {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        List<WorkStaffRecord> recordList =workStaffBasicInfo.getRecordList();
+        if(recordList!=null&&recordList.size()>0){
+            for(WorkStaffRecord newRecord:recordList){
+                Class<? extends WorkStaffRecord> newClass = newRecord.getClass();
+                Field[] declaredFields = newClass.getDeclaredFields();
+                if(newRecord.getId()!=null&&!"1".equals(newRecord.getDelFlag())&&!"".equals(newRecord.getId())){
+                    if(newRecord.getFile()!=null&&!newRecord.getFile().isEmpty()&&newRecord.getFile().getSize()>0){
+                        MultipartFile file = newRecord.getFile();
+                        newRecord.setFilePath(this.uploadFile(file,newRecord.getFilePath()));
+                    }
+                    WorkStaffRecord oldRecord=this.get(newRecord.getId());
+                    if(oldRecord!=null){
+                        Class<? extends WorkStaffRecord> oldClass = oldRecord.getClass();
+                        for (Field field : declaredFields) {
+                            String name = field.getName();
+                            if("name".equals(name)||"num".equals(name)||"filePath".equals(name)||"status".equals(name)||"fileName".equals(name)){
+                                String methodName = "get"+name.substring(0,1).toUpperCase()+name.substring(1);
+                                WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+                                workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+                                workStaffAchivesLog.setModule("电子档案");
+                                workStaffAchivesLog.setSonId(newRecord.getId());
+                                workStaffAchivesLog.setFields(name);
+                                workStaffAchivesLog.setState("1");
+                                try {
+                                    Object newInvoke = newClass.getMethod(methodName).invoke(newRecord);//修改后
+                                    Object oldInvoke = oldClass.getMethod(methodName).invoke(oldRecord);//修改前
+                                    String describes=EDU_MAP.get(name);
+                                    if(newInvoke instanceof String){
+                                        String newValue=newInvoke.toString();
+                                        String oldValue=oldInvoke.toString();
+                                        if(!newValue.equals(oldValue)){
+                                            if("name".equals(name)){
+                                                workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                                        "电子档案",describes,name,
+                                                        oldValue,
+                                                        newValue,
+                                                        oldValue,newValue,newRecord.getId(),"修改");
+                                            }else{
+                                                workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                                        "电子档案",describes,name,
+                                                        oldInvoke.toString(),newInvoke.toString(),
+                                                        oldInvoke.toString(),newInvoke.toString(),newRecord.getId(),"修改");
+                                            }
+                                        }
+                                    }
+                                    if(newInvoke instanceof Date){//日期
+                                        String newDate="";
+                                        String oldDate="";
+                                        if(newInvoke!=null){
+                                            newDate=sdf.format(newInvoke);
+                                        }
+                                        if (oldInvoke!=null){
+                                            oldDate=sdf.format(oldInvoke);
+                                        }
+                                        if(!newDate.equals(oldDate)){
+                                            workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                                    "电子档案",describes,name,
+                                                    oldDate,newDate,oldDate,newDate,newRecord.getId(),"修改");
+                                        }
+                                    }
+                                } catch (NoSuchMethodException e) {
+                                    e.printStackTrace();
+                                } catch (IllegalAccessException e) {
+                                    e.printStackTrace();
+                                } catch (InvocationTargetException e) {
+                                    e.printStackTrace();
+                                }
+                            }
+                        }
+
+                    }
+                }else if((newRecord.getId()==null||"".equals(newRecord.getId()))&&"0".equals(newRecord.getDelFlag())){//新增
+                    if(newRecord.getFile()!=null&&!newRecord.getFile().isEmpty()&&newRecord.getFile().getSize()>0){
+                        MultipartFile file = newRecord.getFile();
+                        newRecord.setFilePath(this.uploadFile(file,newRecord.getFilePath()));
+                    }
+                    String newId=IdGen.uuid();
+                    for (Field field : declaredFields) {
+                        String name = field.getName();
+                        if("name".equals(name)||"num".equals(name)||"filePath".equals(name)||"status".equals(name)||"fileName".equals(name)){
+                            String methodName = "get"+name.substring(0,1).toUpperCase()+name.substring(1);
+                            WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+                            workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+                            workStaffAchivesLog.setModule("电子档案");
+                            workStaffAchivesLog.setSonId(newId);
+                            workStaffAchivesLog.setFields(name);
+                            workStaffAchivesLog.setState("1");
+                            try {
+                                Object newInvoke = newClass.getMethod(methodName).invoke(newRecord);//修改后
+                                String describes=EDU_MAP.get(name);
+                                if(newInvoke instanceof String){
+                                    String newValue=newInvoke.toString();
+                                    if("name".equals(name)){
+                                        workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                                "电子档案",describes,name,
+                                                "",
+                                                newValue,
+                                                "",newValue,newId,"新增");
+                                    }else{
+                                        workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                                "电子档案",describes,name,
+                                                "",newInvoke.toString(),
+                                                "",newInvoke.toString(),newId,"新增");
+                                    }
+                                }
+                                if(newInvoke instanceof Date){//日期
+                                    String newDate=sdf.format(newInvoke);
+                                    workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                            "电子档案",describes,name,
+                                            "",newDate,"",newDate,newId,"新增");
+                                };
+                            } catch (NoSuchMethodException e) {
+                                e.printStackTrace();
+                            } catch (IllegalAccessException e) {
+                                e.printStackTrace();
+                            } catch (InvocationTargetException e) {
+                                e.printStackTrace();
+                            }
+                        }
+                    }
+                }else if(newRecord.getId()!=null&&"1".equals(newRecord.getDelFlag())&&!"".equals(newRecord.getId())){//删除
+                    WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+                    workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+                    workStaffAchivesLog.setModule("电子档案");
+                    workStaffAchivesLog.setSonId(newRecord.getId());
+                    workStaffAchivesLog.setType("删除");
+                    workStaffAchivesLog.setState("1");
+                    workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                            "电子档案","","",
+                            "","",
+                            "","",newRecord.getId(),"删除");
+                }
+            }
+        }
+    }
+}

+ 380 - 0
src/main/java/com/jeeplus/modules/workstaff/service/WorkStaffRewardsService.java

@@ -0,0 +1,380 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workstaff.service;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.jeeplus.common.utils.IdGen;
+import com.jeeplus.common.utils.StringUtils;
+import com.jeeplus.modules.sys.dao.UserDao;
+import com.jeeplus.modules.sys.entity.User;
+import com.jeeplus.modules.sys.utils.DictUtils;
+import com.jeeplus.modules.workstaff.entity.WorkStaffBasicInfo;
+import com.jeeplus.modules.workstaff.entity.WorkStaffLanguages;
+import com.jeeplus.modules.workstaffachiveslog.entity.WorkStaffAchivesLog;
+import com.jeeplus.modules.workstaffachiveslog.service.WorkStaffAchivesLogService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.jeeplus.common.persistence.Page;
+import com.jeeplus.common.service.CrudService;
+import com.jeeplus.modules.workstaff.entity.WorkStaffRewards;
+import com.jeeplus.modules.workstaff.dao.WorkStaffRewardsDao;
+import org.springframework.web.multipart.MultipartFile;
+
+/**
+ * 奖惩情况Service
+ * @author ssrh
+ * @version 2018-07-27
+ */
+@Service
+@Transactional(readOnly = true)
+public class WorkStaffRewardsService extends CrudService<WorkStaffRewardsDao, WorkStaffRewards> {
+    @Autowired
+    private WorkStaffAchivesLogService workStaffAchivesLogService;
+    @Autowired
+    private UserDao userDao;
+	public WorkStaffRewards get(String id) {
+		return super.get(id);
+	}
+	
+	public List<WorkStaffRewards> findList(WorkStaffRewards workStaffRewards) {
+		return super.findList(workStaffRewards);
+	}
+	
+	public Page<WorkStaffRewards> findPage(Page<WorkStaffRewards> page, WorkStaffRewards workStaffRewards) {
+		return super.findPage(page, workStaffRewards);
+	}
+	
+	@Transactional(readOnly = false)
+	public void save(WorkStaffRewards workStaffRewards) {
+		super.save(workStaffRewards);
+	}
+	
+	@Transactional(readOnly = false)
+	public void delete(WorkStaffRewards workStaffRewards) {
+		super.delete(workStaffRewards);
+	}
+
+
+    public boolean save(WorkStaffBasicInfo workStaffBasicInfo,boolean first) {
+        if(workStaffBasicInfo==null|| StringUtils.isBlank(workStaffBasicInfo.getId())){
+            return false;
+        }
+        List<WorkStaffRewards> list = workStaffBasicInfo.getRewardsList();
+        if(list==null||list.size()<=0){
+            return false;
+        }
+        boolean flag=false;
+        for (WorkStaffRewards entity : list) {
+            if(entity!=null&&"1".equals(entity.getDelFlag())&&StringUtils.isBlank(entity.getId())){
+                continue;
+            }
+            if(entity!=null&&"1".equals(entity.getDelFlag())){
+                dao.deleteByLogic(entity);
+                continue;
+            }
+            if (entity!=null){
+                entity.setStaff(workStaffBasicInfo.getId());
+                this.save(entity);
+                if(first){
+                    entity.setId(null);
+                }
+                flag =true;
+            }
+        }
+        return flag;
+    }
+
+    public void query(WorkStaffBasicInfo workStaffBasicInfo) {
+        if(workStaffBasicInfo==null|| StringUtils.isBlank(workStaffBasicInfo.getId())){
+            return;
+        }
+        WorkStaffRewards entity = new WorkStaffRewards();
+        entity.setStaff(workStaffBasicInfo.getId());
+        workStaffBasicInfo.setRewardsList(this.findList(entity));
+    }
+    private static Map<String,String> EDU_MAP = Maps.newHashMap();//教育经历
+
+    static{//教育经历
+        EDU_MAP.put("type", "奖惩类型");
+        EDU_MAP.put("name", "奖惩名称");
+        EDU_MAP.put("atTime", "时间");
+        EDU_MAP.put("grade", "级别");
+        EDU_MAP.put("reason", "原因");
+        EDU_MAP.put("organization", "授予机构");
+    }
+
+    public boolean saveApply(WorkStaffBasicInfo workStaffBasicInfo,boolean first) {
+        if(workStaffBasicInfo==null|| StringUtils.isBlank(workStaffBasicInfo.getId())){
+            return false;
+        }
+        List<WorkStaffRewards> list = workStaffBasicInfo.getRewardsList();
+        if(list==null||list.size()<=0){
+            return false;
+        }
+        boolean flag = false;
+        User u=userDao.get(workStaffBasicInfo.getUserId());
+        for (WorkStaffRewards entity : list) {
+            entity.setStaff(workStaffBasicInfo.getId());
+            WorkStaffRewards workStaffLanguages=dao.get(entity.getId());
+            if(workStaffLanguages==null){
+                entity.setCreateBy(u);
+                entity.setCreateDate(new Date());
+                entity.setUpdateBy(u);
+                entity.setUpdateDate(new Date());
+                dao.insert(entity);
+            }else{
+                this.save(entity);
+            }
+            if(entity!=null&&"1".equals(entity.getDelFlag())){
+                dao.deleteByLogic(entity);
+                continue;
+            }
+            flag =true;
+        }
+        dao.updateFalt(workStaffBasicInfo.getId());
+        return flag;
+    }
+    public void querys(WorkStaffBasicInfo workStaffBasicInfo) {
+        SimpleDateFormat dateFormat1 = new SimpleDateFormat("yyyy-MM-dd");
+        if(workStaffBasicInfo==null|| StringUtils.isBlank(workStaffBasicInfo.getId())){
+            return;
+        }
+        WorkStaffRewards entity = new WorkStaffRewards();
+        entity.setStaff(workStaffBasicInfo.getId());
+        List<WorkStaffRewards> list=this.findList(entity);
+        List<WorkStaffRewards> newList=Lists.newArrayList();
+        if(list!=null&&list.size()>0){//修改
+            for(WorkStaffRewards workStaffRewards:list){
+                Class<? extends WorkStaffRewards> newClass = workStaffRewards.getClass();
+                Field[] declaredFields = newClass.getDeclaredFields();
+                for (Field field : declaredFields) {
+                    String name = field.getName();
+                    if("type".equals(name)||"name".equals(name)||"atTime".equals(name)||"grade".equals(name)||"reason".equals(name)
+                            || "organization".equals(name)){
+                        String setMethod = "set"+name.substring(0,1).toUpperCase()+name.substring(1);
+                        String getMethod = "get"+name.substring(0,1).toUpperCase()+name.substring(1);
+                        WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+                        workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+                        workStaffAchivesLog.setModule("奖惩情况");
+                        workStaffAchivesLog.setSonId(workStaffRewards.getId());
+                        workStaffAchivesLog.setFields(name);
+                        workStaffAchivesLog.setType("修改");
+                        workStaffAchivesLog.setState("1");
+                        List<WorkStaffAchivesLog> logs=workStaffAchivesLogService.findList(workStaffAchivesLog);
+                        try {
+                            Object newInvoke = newClass.getMethod(getMethod).invoke(workStaffRewards);//修改后
+                            if(newInvoke instanceof String){
+                                Method setReadOnly = workStaffRewards.getClass().getMethod(setMethod, String.class);
+                                if(logs!=null&&logs.size()>0){
+                                    setReadOnly.invoke(workStaffRewards,logs.get(0).getNewKey());
+                                }
+                            }
+                            if(newInvoke instanceof Date){//日期
+                                Method setReadOnly = workStaffRewards.getClass().getMethod(setMethod, Date.class);
+                                if(logs!=null&&logs.size()>0){
+                                    Date myDate = dateFormat1.parse(logs.get(0).getNewKey());
+                                    setReadOnly.invoke(workStaffRewards,myDate);
+                                }
+                            }
+                        } catch (NoSuchMethodException e) {
+                            e.printStackTrace();
+                        } catch (IllegalAccessException e) {
+                            e.printStackTrace();
+                        } catch (InvocationTargetException e) {
+                            e.printStackTrace();
+                        } catch (ParseException e) {
+                            e.printStackTrace();
+                        }
+                    }
+                }
+                newList.add(workStaffRewards);
+            }
+        }
+        //新增
+        WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+        workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+        workStaffAchivesLog.setModule("奖惩情况");
+        workStaffAchivesLog.setType("新增");
+        workStaffAchivesLog.setState("1");
+        List<WorkStaffAchivesLog> sonIds=workStaffAchivesLogService.findSonId(workStaffAchivesLog);
+        if(sonIds!=null&&sonIds.size()>0){
+            for(WorkStaffAchivesLog w:sonIds){
+                workStaffAchivesLog.setSonId(w.getSonId());
+                WorkStaffRewards workStaffRewards = new WorkStaffRewards();
+                workStaffRewards.setId(w.getSonId());
+                workStaffRewards.setDelFlag("0");
+                workStaffRewards.setStaff(workStaffBasicInfo.getId());
+                Class<? extends WorkStaffRewards> newClass = workStaffRewards.getClass();
+                Field[] declaredFields = newClass.getDeclaredFields();
+                for (Field field : declaredFields) {
+                    String name = field.getName();
+                    if("type".equals(name)||"name".equals(name)||"atTime".equals(name)||"grade".equals(name)||"reason".equals(name)
+                            || "organization".equals(name)){
+                        String setMethod = "set"+name.substring(0,1).toUpperCase()+name.substring(1);
+                        String getMethod = "get"+name.substring(0,1).toUpperCase()+name.substring(1);
+                        workStaffAchivesLog.setFields(name);
+                        List<WorkStaffAchivesLog> logs=workStaffAchivesLogService.findList(workStaffAchivesLog);
+                        try {
+                                Method setReadOnly = workStaffRewards.getClass().getMethod(setMethod, String.class);
+                                if(logs!=null&&logs.size()>0){
+                                    setReadOnly.invoke(workStaffRewards,logs.get(0).getNewKey());
+                                }
+
+                        } catch (NoSuchMethodException e) {
+                            e.printStackTrace();
+                        } catch (IllegalAccessException e) {
+                            e.printStackTrace();
+                        } catch (InvocationTargetException e) {
+                            e.printStackTrace();
+                        }
+                    }
+                }
+                newList.add(workStaffRewards);
+            }
+        }
+        //删除
+        WorkStaffAchivesLog delLog=new WorkStaffAchivesLog();
+        delLog.setStaffId(workStaffBasicInfo.getId());
+        delLog.setModule("奖惩情况");
+        delLog.setType("删除");
+        workStaffAchivesLog.setState("1");
+        List<WorkStaffAchivesLog> dellogs=workStaffAchivesLogService.findList(delLog);
+        if(dellogs!=null&&dellogs.size()>0){
+            for(WorkStaffAchivesLog w:dellogs){
+                newList.remove(dao.get(w.getSonId()));
+            }
+        }
+        workStaffBasicInfo.setRewardsList(newList);
+    }
+    @Transactional(readOnly = false)
+    public void saveEdu(WorkStaffBasicInfo workStaffBasicInfo) {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        List<WorkStaffRewards> rewardsList =workStaffBasicInfo.getRewardsList();
+        if(rewardsList!=null&&rewardsList.size()>0){
+            for(WorkStaffRewards newRewards:rewardsList){
+                Class<? extends WorkStaffRewards> newClass = newRewards.getClass();
+                Field[] declaredFields = newClass.getDeclaredFields();
+                if(newRewards.getId()!=null&&!"1".equals(newRewards.getDelFlag())&&!"".equals(newRewards.getId())){
+                    WorkStaffRewards oldRewards=this.get(newRewards.getId());
+                    if(oldRewards!=null){
+                        Class<? extends WorkStaffRewards> oldClass = oldRewards.getClass();
+                        for (Field field : declaredFields) {
+                            String name = field.getName();
+                            if("type".equals(name)||"name".equals(name)||"atTime".equals(name)||"grade".equals(name)||"reason".equals(name)
+                                    || "organization".equals(name)){
+                                String methodName = "get"+name.substring(0,1).toUpperCase()+name.substring(1);
+                                WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+                                workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+                                workStaffAchivesLog.setModule("奖惩情况");
+                                workStaffAchivesLog.setSonId(newRewards.getId());
+                                workStaffAchivesLog.setFields(name);
+                                workStaffAchivesLog.setState("1");
+                                try {
+                                    Object newInvoke = newClass.getMethod(methodName).invoke(newRewards);//修改后
+                                    Object oldInvoke = oldClass.getMethod(methodName).invoke(oldRewards);//修改前
+                                    String describes=EDU_MAP.get(name);
+                                    if(newInvoke instanceof String){
+                                        String newValue=newInvoke.toString();
+                                        String oldValue=oldInvoke.toString();
+                                        if(!newValue.equals(oldValue)){
+                                                workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                                        "奖惩情况",describes,name,
+                                                        oldInvoke.toString(),newInvoke.toString(),
+                                                        oldInvoke.toString(),newInvoke.toString(),newRewards.getId(),"修改");
+
+                                        }
+                                    }
+                                    if(newInvoke instanceof Date){//日期
+                                        String newDate="";
+                                        String oldDate="";
+                                        if(newInvoke!=null){
+                                            newDate=sdf.format(newInvoke);
+                                        }
+                                        if (oldInvoke!=null){
+                                            oldDate=sdf.format(oldInvoke);
+                                        }
+                                        if(!newDate.equals(oldDate)){
+                                            workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                                    "奖惩情况",describes,name,
+                                                    oldDate,newDate,oldDate,newDate,newRewards.getId(),"修改");
+                                        }
+                                    }
+                                } catch (NoSuchMethodException e) {
+                                    e.printStackTrace();
+                                } catch (IllegalAccessException e) {
+                                    e.printStackTrace();
+                                } catch (InvocationTargetException e) {
+                                    e.printStackTrace();
+                                }
+                            }
+                        }
+
+                    }
+                }else if((newRewards.getId()==null||"".equals(newRewards.getId()))&&"0".equals(newRewards.getDelFlag())){//新增
+                    String newId=IdGen.uuid();
+                    for (Field field : declaredFields) {
+                        String name = field.getName();
+                        if("type".equals(name)||"name".equals(name)||"atTime".equals(name)||"grade".equals(name)||"reason".equals(name)
+                                || "organization".equals(name)){
+                            String methodName = "get"+name.substring(0,1).toUpperCase()+name.substring(1);
+                            WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+                            workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+                            workStaffAchivesLog.setModule("奖惩情况");
+                            workStaffAchivesLog.setSonId(newId);
+                            workStaffAchivesLog.setFields(name);
+                            workStaffAchivesLog.setState("1");
+                            try {
+                                Object newInvoke = newClass.getMethod(methodName).invoke(newRewards);//修改后
+                                String describes=EDU_MAP.get(name);
+                                if(newInvoke instanceof String){
+                                    String newValue=newInvoke.toString();
+                                        workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                                "奖惩情况",describes,name,
+                                                "",newInvoke.toString(),
+                                                "",newInvoke.toString(),newId,"新增");
+
+                                }
+                                if(newInvoke instanceof Date){//日期
+                                    String newDate=sdf.format(newInvoke);
+                                    workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                            "奖惩情况",describes,name,
+                                            "",newDate,"",newDate,newId,"新增");
+                                };
+                            } catch (NoSuchMethodException e) {
+                                e.printStackTrace();
+                            } catch (IllegalAccessException e) {
+                                e.printStackTrace();
+                            } catch (InvocationTargetException e) {
+                                e.printStackTrace();
+                            }
+                        }
+                    }
+                }else if(newRewards.getId()!=null&&"1".equals(newRewards.getDelFlag())&&!"".equals(newRewards.getId())){//删除
+                    WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+                    workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+                    workStaffAchivesLog.setModule("奖惩情况");
+                    workStaffAchivesLog.setSonId(newRewards.getId());
+                    workStaffAchivesLog.setType("删除");
+                    workStaffAchivesLog.setState("1");
+                    workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                            "奖惩情况","","",
+                            "","",
+                            "","",newRewards.getId(),"删除");
+                }
+            }
+        }
+    }
+}

+ 379 - 0
src/main/java/com/jeeplus/modules/workstaff/service/WorkStaffSocialPositionService.java

@@ -0,0 +1,379 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workstaff.service;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.jeeplus.common.utils.IdGen;
+import com.jeeplus.common.utils.StringUtils;
+import com.jeeplus.modules.sys.dao.UserDao;
+import com.jeeplus.modules.sys.entity.User;
+import com.jeeplus.modules.sys.utils.DictUtils;
+import com.jeeplus.modules.workstaff.entity.WorkStaffBasicInfo;
+import com.jeeplus.modules.workstaff.entity.WorkStaffEducation;
+import com.jeeplus.modules.workstaffachiveslog.entity.WorkStaffAchivesLog;
+import com.jeeplus.modules.workstaffachiveslog.service.WorkStaffAchivesLogService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.jeeplus.common.persistence.Page;
+import com.jeeplus.common.service.CrudService;
+import com.jeeplus.modules.workstaff.entity.WorkStaffSocialPosition;
+import com.jeeplus.modules.workstaff.dao.WorkStaffSocialPositionDao;
+import org.springframework.web.multipart.MultipartFile;
+
+/**
+ * 社会及行业职务Service
+ * @author ssrh
+ * @version 2018-07-27
+ */
+@Service
+@Transactional(readOnly = true)
+public class WorkStaffSocialPositionService extends CrudService<WorkStaffSocialPositionDao, WorkStaffSocialPosition> {
+    @Autowired
+    private WorkStaffAchivesLogService workStaffAchivesLogService;
+    @Autowired
+    private UserDao userDao;
+	public WorkStaffSocialPosition get(String id) {
+		return super.get(id);
+	}
+	
+	public List<WorkStaffSocialPosition> findList(WorkStaffSocialPosition workStaffSocialPosition) {
+		return super.findList(workStaffSocialPosition);
+	}
+	
+	public Page<WorkStaffSocialPosition> findPage(Page<WorkStaffSocialPosition> page, WorkStaffSocialPosition workStaffSocialPosition) {
+		return super.findPage(page, workStaffSocialPosition);
+	}
+	
+	@Transactional(readOnly = false)
+	public void save(WorkStaffSocialPosition workStaffSocialPosition) {
+		super.save(workStaffSocialPosition);
+	}
+	
+	@Transactional(readOnly = false)
+	public void delete(WorkStaffSocialPosition workStaffSocialPosition) {
+		super.delete(workStaffSocialPosition);
+	}
+
+
+    public boolean save(WorkStaffBasicInfo workStaffBasicInfo,boolean first) {
+        if(workStaffBasicInfo==null|| StringUtils.isBlank(workStaffBasicInfo.getId())){
+            return false;
+        }
+        List<WorkStaffSocialPosition> list = workStaffBasicInfo.getSocialPositionList();
+        if(list==null||list.size()<=0){
+            return false;
+        }
+        boolean flag=false;
+        for (WorkStaffSocialPosition entity : list) {
+            if(entity!=null&&"1".equals(entity.getDelFlag())&&StringUtils.isBlank(entity.getId())){
+                continue;
+            }
+            if(entity!=null&&"1".equals(entity.getDelFlag())){
+                dao.deleteByLogic(entity);
+                continue;
+            }
+            if (entity!=null){
+                entity.setStaff(workStaffBasicInfo.getId());
+                this.save(entity);
+                if(first){
+                    entity.setId(null);
+                }
+                flag = true;
+            }
+        }
+        return flag;
+    }
+
+    public void query(WorkStaffBasicInfo workStaffBasicInfo) {
+        if(workStaffBasicInfo==null|| StringUtils.isBlank(workStaffBasicInfo.getId())){
+            return;
+        }
+        WorkStaffSocialPosition entity = new WorkStaffSocialPosition();
+        entity.setStaff(workStaffBasicInfo.getId());
+        workStaffBasicInfo.setSocialPositionList(this.findList(entity));
+    }
+    private static Map<String,String> EDU_MAP = Maps.newHashMap();//教育经历
+
+    static{//教育经历
+        EDU_MAP.put("name", "职务名称");
+        EDU_MAP.put("startDate", "任职开始日期");
+        EDU_MAP.put("endDate", "任职结束日期");
+        EDU_MAP.put("organization", "任职机构");
+    }
+    public boolean saveApply(WorkStaffBasicInfo workStaffBasicInfo,boolean first) {
+        if(workStaffBasicInfo==null|| StringUtils.isBlank(workStaffBasicInfo.getId())){
+            return false;
+        }
+        List<WorkStaffSocialPosition> list = workStaffBasicInfo.getSocialPositionList();
+        if(list==null||list.size()<=0){
+            return false;
+        }
+        boolean flag = false;
+        User u=userDao.get(workStaffBasicInfo.getUserId());
+        for (WorkStaffSocialPosition entity : list) {
+            entity.setStaff(workStaffBasicInfo.getId());
+            WorkStaffSocialPosition workStaffSocialPosition=dao.get(entity.getId());
+            if(workStaffSocialPosition==null){
+                entity.setCreateBy(u);
+                entity.setCreateDate(new Date());
+                entity.setUpdateBy(u);
+                entity.setUpdateDate(new Date());
+                dao.insert(entity);
+            }else{
+                this.save(entity);
+            }
+            if(entity!=null&&"1".equals(entity.getDelFlag())){
+                dao.deleteByLogic(entity);
+                continue;
+            }
+            flag =true;
+        }
+        dao.updateFalt(workStaffBasicInfo.getId());
+        return flag;
+    }
+    public void querys(WorkStaffBasicInfo workStaffBasicInfo) {
+        SimpleDateFormat dateFormat1 = new SimpleDateFormat("yyyy-MM-dd");
+        if(workStaffBasicInfo==null|| StringUtils.isBlank(workStaffBasicInfo.getId())){
+            return;
+        }
+        WorkStaffSocialPosition entity = new WorkStaffSocialPosition();
+        entity.setStaff(workStaffBasicInfo.getId());
+        List<WorkStaffSocialPosition> list=this.findList(entity);
+        List<WorkStaffSocialPosition> newList=Lists.newArrayList();
+        if(list!=null&&list.size()>0){//修改
+            for(WorkStaffSocialPosition workStaffSocialPosition:list){
+                Class<? extends WorkStaffSocialPosition> newClass = workStaffSocialPosition.getClass();
+                Field[] declaredFields = newClass.getDeclaredFields();
+                for (Field field : declaredFields) {
+                    String name = field.getName();
+                    if("name".equals(name)||"startDate".equals(name)||"endDate".equals(name)||"organization".equals(name)){
+                        String setMethod = "set"+name.substring(0,1).toUpperCase()+name.substring(1);
+                        String getMethod = "get"+name.substring(0,1).toUpperCase()+name.substring(1);
+                        WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+                        workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+                        workStaffAchivesLog.setModule("社会及行业职务");
+                        workStaffAchivesLog.setSonId(workStaffSocialPosition.getId());
+                        workStaffAchivesLog.setFields(name);
+                        workStaffAchivesLog.setType("修改");
+                        workStaffAchivesLog.setState("1");
+                        List<WorkStaffAchivesLog> logs=workStaffAchivesLogService.findList(workStaffAchivesLog);
+                        try {
+                            Object newInvoke = newClass.getMethod(getMethod).invoke(workStaffSocialPosition);//修改后
+                            if(newInvoke instanceof String){
+                                Method setReadOnly = workStaffSocialPosition.getClass().getMethod(setMethod, String.class);
+                                if(logs!=null&&logs.size()>0){
+                                    setReadOnly.invoke(workStaffSocialPosition,logs.get(0).getNewKey());
+                                }
+                            }
+                            if(newInvoke instanceof Date){//日期
+                                Method setReadOnly = workStaffSocialPosition.getClass().getMethod(setMethod, Date.class);
+                                if(logs!=null&&logs.size()>0){
+                                    Date myDate = dateFormat1.parse(logs.get(0).getNewKey());
+                                    setReadOnly.invoke(workStaffSocialPosition,myDate);
+                                }
+                            }
+                        } catch (NoSuchMethodException e) {
+                            e.printStackTrace();
+                        } catch (IllegalAccessException e) {
+                            e.printStackTrace();
+                        } catch (InvocationTargetException e) {
+                            e.printStackTrace();
+                        } catch (ParseException e) {
+                            e.printStackTrace();
+                        }
+                    }
+                }
+                newList.add(workStaffSocialPosition);
+            }
+        }
+        //新增
+        WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+        workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+        workStaffAchivesLog.setModule("社会及行业职务");
+        workStaffAchivesLog.setType("新增");
+        workStaffAchivesLog.setState("1");
+        List<WorkStaffAchivesLog> sonIds=workStaffAchivesLogService.findSonId(workStaffAchivesLog);
+        if(sonIds!=null&&sonIds.size()>0){
+            for(WorkStaffAchivesLog w:sonIds){
+                workStaffAchivesLog.setSonId(w.getSonId());
+                WorkStaffSocialPosition workStaffSocialPosition = new WorkStaffSocialPosition();
+                workStaffSocialPosition.setId(w.getSonId());
+                workStaffSocialPosition.setDelFlag("0");
+                workStaffSocialPosition.setStaff(workStaffBasicInfo.getId());
+                Class<? extends WorkStaffSocialPosition> newClass = workStaffSocialPosition.getClass();
+                Field[] declaredFields = newClass.getDeclaredFields();
+                for (Field field : declaredFields) {
+                    String name = field.getName();
+                    if("name".equals(name)||"startDate".equals(name)||"endDate".equals(name)||"organization".equals(name)){
+                        String setMethod = "set"+name.substring(0,1).toUpperCase()+name.substring(1);
+                        String getMethod = "get"+name.substring(0,1).toUpperCase()+name.substring(1);
+                        workStaffAchivesLog.setFields(name);
+                        List<WorkStaffAchivesLog> logs=workStaffAchivesLogService.findList(workStaffAchivesLog);
+                        try {
+                            if("startDate".equals(name)||"endDate".equals(name)){//日期
+                                Method setReadOnly = workStaffSocialPosition.getClass().getMethod(setMethod, Date.class);
+                                if(logs!=null&&logs.size()>0){
+                                    Date myDate = dateFormat1.parse(logs.get(0).getNewKey());
+                                    setReadOnly.invoke(workStaffSocialPosition,myDate);
+                                }
+                            }else{
+                                Method setReadOnly = workStaffSocialPosition.getClass().getMethod(setMethod, String.class);
+                                if(logs!=null&&logs.size()>0){
+                                    setReadOnly.invoke(workStaffSocialPosition,logs.get(0).getNewKey());
+                                }
+                            }
+                        } catch (NoSuchMethodException e) {
+                            e.printStackTrace();
+                        } catch (IllegalAccessException e) {
+                            e.printStackTrace();
+                        } catch (InvocationTargetException e) {
+                            e.printStackTrace();
+                        } catch (ParseException e) {
+                            e.printStackTrace();
+                        }
+                    }
+                }
+                newList.add(workStaffSocialPosition);
+            }
+        }
+        //删除
+        WorkStaffAchivesLog delLog=new WorkStaffAchivesLog();
+        delLog.setStaffId(workStaffBasicInfo.getId());
+        delLog.setModule("社会及行业职务");
+        delLog.setType("删除");
+        workStaffAchivesLog.setState("1");
+        List<WorkStaffAchivesLog> dellogs=workStaffAchivesLogService.findList(delLog);
+        if(dellogs!=null&&dellogs.size()>0){
+            for(WorkStaffAchivesLog w:dellogs){
+                newList.remove(dao.get(w.getSonId()));
+            }
+        }
+        workStaffBasicInfo.setSocialPositionList(newList);
+    }
+    @Transactional(readOnly = false)
+    public void saveEdu(WorkStaffBasicInfo workStaffBasicInfo) {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        List<WorkStaffSocialPosition> socialPositionList =workStaffBasicInfo.getSocialPositionList();
+        if(socialPositionList!=null&&socialPositionList.size()>0){
+            for(WorkStaffSocialPosition newSocialPosition:socialPositionList){
+                Class<? extends WorkStaffSocialPosition> newClass = newSocialPosition.getClass();
+                Field[] declaredFields = newClass.getDeclaredFields();
+                if(newSocialPosition.getId()!=null&&!"1".equals(newSocialPosition.getDelFlag())&&!"".equals(newSocialPosition.getId())){
+                    WorkStaffSocialPosition oldSocialPosition=this.get(newSocialPosition.getId());
+                    if(oldSocialPosition!=null){
+                        Class<? extends WorkStaffSocialPosition> oldClass = oldSocialPosition.getClass();
+                        for (Field field : declaredFields) {
+                            String name = field.getName();
+                            if("name".equals(name)||"startDate".equals(name)||"endDate".equals(name)||"organization".equals(name)){
+                                String methodName = "get"+name.substring(0,1).toUpperCase()+name.substring(1);
+                                WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+                                workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+                                workStaffAchivesLog.setModule("社会及行业职务");
+                                workStaffAchivesLog.setSonId(newSocialPosition.getId());
+                                workStaffAchivesLog.setFields(name);
+                                workStaffAchivesLog.setState("1");
+                                try {
+                                    Object newInvoke = newClass.getMethod(methodName).invoke(newSocialPosition);//修改后
+                                    Object oldInvoke = oldClass.getMethod(methodName).invoke(oldSocialPosition);//修改前
+                                    String describes=EDU_MAP.get(name);
+                                    if(newInvoke instanceof String){
+                                        String newValue=newInvoke.toString();
+                                        String oldValue=oldInvoke.toString();
+                                        if(!newValue.equals(oldValue)){
+                                                workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                                        "社会及行业职务",describes,name,
+                                                        oldInvoke.toString(),newInvoke.toString(),
+                                                        oldInvoke.toString(),newInvoke.toString(),newSocialPosition.getId(),"修改");
+                                        }
+                                    }
+                                    if(newInvoke instanceof Date){//日期
+                                        String newDate="";
+                                        String oldDate="";
+                                        if(newInvoke!=null){
+                                            newDate=sdf.format(newInvoke);
+                                        }
+                                        if (oldInvoke!=null){
+                                            oldDate=sdf.format(oldInvoke);
+                                        }
+                                        if(!newDate.equals(oldDate)){
+                                            workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                                    "社会及行业职务",describes,name,
+                                                    oldDate,newDate,oldDate,newDate,newSocialPosition.getId(),"修改");
+                                        }
+                                    }
+                                } catch (NoSuchMethodException e) {
+                                    e.printStackTrace();
+                                } catch (IllegalAccessException e) {
+                                    e.printStackTrace();
+                                } catch (InvocationTargetException e) {
+                                    e.printStackTrace();
+                                }
+                            }
+                        }
+                    }
+                }else if((newSocialPosition.getId()==null||"".equals(newSocialPosition.getId()))&&"0".equals(newSocialPosition.getDelFlag())){//新增
+                    String newId=IdGen.uuid();
+                    for (Field field : declaredFields) {
+                        String name = field.getName();
+                        if("name".equals(name)||"startDate".equals(name)||"endDate".equals(name)||"organization".equals(name)){
+                            String methodName = "get"+name.substring(0,1).toUpperCase()+name.substring(1);
+                            WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+                            workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+                            workStaffAchivesLog.setModule("社会及行业职务");
+                            workStaffAchivesLog.setSonId(newId);
+                            workStaffAchivesLog.setFields(name);
+                            workStaffAchivesLog.setState("1");
+                            try {
+                                Object newInvoke = newClass.getMethod(methodName).invoke(newSocialPosition);//修改后
+                                String describes=EDU_MAP.get(name);
+                                if(newInvoke instanceof String){
+                                    String newValue=newInvoke.toString();
+                                        workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                                "社会及行业职务",describes,name,
+                                                "",newInvoke.toString(),
+                                                "",newInvoke.toString(),newId,"新增");
+                                }
+                                if(newInvoke instanceof Date){//日期
+                                    String newDate=sdf.format(newInvoke);
+                                    workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                            "社会及行业职务",describes,name,
+                                            "",newDate,"",newDate,newId,"新增");
+                                };
+                            } catch (NoSuchMethodException e) {
+                                e.printStackTrace();
+                            } catch (IllegalAccessException e) {
+                                e.printStackTrace();
+                            } catch (InvocationTargetException e) {
+                                e.printStackTrace();
+                            }
+                        }
+                    }
+                }else if(newSocialPosition.getId()!=null&&"1".equals(newSocialPosition.getDelFlag())&&!"".equals(newSocialPosition.getId())){//删除
+                    WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+                    workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+                    workStaffAchivesLog.setModule("社会及行业职务");
+                    workStaffAchivesLog.setSonId(newSocialPosition.getId());
+                    workStaffAchivesLog.setType("删除");
+                    workStaffAchivesLog.setState("1");
+                    workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                            "社会及行业职务","","",
+                            "","",
+                            "","",newSocialPosition.getId(),"删除");
+                }
+            }
+        }
+    }
+}

+ 429 - 0
src/main/java/com/jeeplus/modules/workstaff/service/WorkStaffTitleService.java

@@ -0,0 +1,429 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workstaff.service;
+
+import java.io.InputStream;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.jeeplus.common.bos.BOSClientUtil;
+import com.jeeplus.common.config.Global;
+import com.jeeplus.common.oss.OSSClientUtil;
+import com.jeeplus.common.utils.DateUtils;
+import com.jeeplus.common.utils.IdGen;
+import com.jeeplus.common.utils.StringUtils;
+import com.jeeplus.modules.sys.dao.UserDao;
+import com.jeeplus.modules.sys.entity.User;
+import com.jeeplus.modules.sys.utils.DictUtils;
+import com.jeeplus.modules.workstaff.entity.WorkStaffBasicInfo;
+import com.jeeplus.modules.workstaff.entity.WorkStaffEducation;
+import com.jeeplus.modules.workstaffachiveslog.entity.WorkStaffAchivesLog;
+import com.jeeplus.modules.workstaffachiveslog.service.WorkStaffAchivesLogService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.jeeplus.common.persistence.Page;
+import com.jeeplus.common.service.CrudService;
+import com.jeeplus.modules.workstaff.entity.WorkStaffTitle;
+import com.jeeplus.modules.workstaff.dao.WorkStaffTitleDao;
+import org.springframework.web.multipart.MultipartFile;
+
+/**
+ * 职称Service
+ * @author ssrh
+ * @version 2018-07-27
+ */
+@Service
+@Transactional(readOnly = true)
+public class WorkStaffTitleService extends CrudService<WorkStaffTitleDao, WorkStaffTitle> {
+    @Autowired
+    private WorkStaffAchivesLogService workStaffAchivesLogService;
+    @Autowired
+    private UserDao userDao;
+	public WorkStaffTitle get(String id) {
+		return super.get(id);
+	}
+	
+	public List<WorkStaffTitle> findList(WorkStaffTitle workStaffTitle) {
+		return super.findList(workStaffTitle);
+	}
+	
+	public Page<WorkStaffTitle> findPage(Page<WorkStaffTitle> page, WorkStaffTitle workStaffTitle) {
+		return super.findPage(page, workStaffTitle);
+	}
+	
+	@Transactional(readOnly = false)
+	public void save(WorkStaffTitle workStaffTitle) {
+		super.save(workStaffTitle);
+	}
+	
+	@Transactional(readOnly = false)
+	public void delete(WorkStaffTitle workStaffTitle) {
+		super.delete(workStaffTitle);
+	}
+
+
+    public boolean save(WorkStaffBasicInfo workStaffBasicInfo,boolean first) {
+        if(workStaffBasicInfo==null|| StringUtils.isBlank(workStaffBasicInfo.getId())){
+            return false;
+        }
+        List<WorkStaffTitle> list = workStaffBasicInfo.getTitleList();
+        if(list==null||list.size()<=0){
+            return false;
+        }
+        boolean flag=false;
+        for (WorkStaffTitle entity : list) {
+            if(entity!=null&&"1".equals(entity.getDelFlag())&&StringUtils.isBlank(entity.getId())){
+                continue;
+            }
+            if(entity!=null&&"1".equals(entity.getDelFlag())){
+                dao.deleteByLogic(entity);
+                continue;
+            }
+            if (entity!=null){
+                if(entity.getFile()!=null&&!entity.getFile().isEmpty()&&entity.getFile().getSize()>0){
+                    MultipartFile file = entity.getFile();
+                    entity.setFileName(file.getOriginalFilename());
+                    entity.setFilePath(this.uploadFile(file,entity.getFilePath()));
+                }
+                entity.setStaffId(workStaffBasicInfo.getId());
+                this.save(entity);
+                if(first){
+                    entity.setId(null);
+                    entity.setFilePath("");
+                }
+                flag = true;
+            }
+        }
+        return flag;
+    }
+
+    public String uploadFile(MultipartFile file, String filePath){
+        String date = DateUtils.formatDate(new Date(),"yyMMddHHmm");
+        try {
+            if (file != null && file.getSize() > 0) {
+                String path = new StringBuilder("/employeeInfo/").append(date)
+                        .append(file.getOriginalFilename()).toString();
+                InputStream inputStream = file.getInputStream();
+                BOSClientUtil bosClientUtil = new BOSClientUtil();
+                String url = bosClientUtil.upload(path, inputStream);
+                return url;
+            }
+        }catch (Exception e){
+            logger.error("上传文件失败!");
+        }
+        return null;
+    }
+
+    public void query(WorkStaffBasicInfo workStaffBasicInfo) {
+        if(workStaffBasicInfo==null|| StringUtils.isBlank(workStaffBasicInfo.getId())){
+            return;
+        }
+        WorkStaffTitle entity = new WorkStaffTitle();
+        entity.setStaffId(workStaffBasicInfo.getId());
+        workStaffBasicInfo.setTitleList(this.findList(entity));
+    }
+
+    private static Map<String,String> EDU_MAP = Maps.newHashMap();//教育经历
+
+    static{//教育经历
+        EDU_MAP.put("name", "职称名称");
+        EDU_MAP.put("grade", "职称等级");
+        EDU_MAP.put("startDate", "取得日期");
+        EDU_MAP.put("pathway", "取得途径");
+        EDU_MAP.put("approvalAuthority", "审批单位");
+        EDU_MAP.put("startDate", "入学日期");
+        EDU_MAP.put("filePath", "文件");
+        EDU_MAP.put("fileName", "文件名");
+    }
+
+    public boolean saveApply(WorkStaffBasicInfo workStaffBasicInfo,boolean first) {
+        if(workStaffBasicInfo==null|| StringUtils.isBlank(workStaffBasicInfo.getId())){
+            return false;
+        }
+        List<WorkStaffTitle> list = workStaffBasicInfo.getTitleList();
+        if(list==null||list.size()<=0){
+            return false;
+        }
+        boolean flag = false;
+        User u=userDao.get(workStaffBasicInfo.getUserId());
+        for (WorkStaffTitle entity : list) {
+            entity.setStaffId(workStaffBasicInfo.getId());
+            WorkStaffTitle workStaffTitle=dao.get(entity.getId());
+            if(workStaffTitle==null){
+                entity.setCreateBy(u);
+                entity.setCreateDate(new Date());
+                entity.setUpdateBy(u);
+                entity.setUpdateDate(new Date());
+                dao.insert(entity);
+            }else{
+                this.save(entity);
+            }
+            if(entity!=null&&"1".equals(entity.getDelFlag())){
+                dao.deleteByLogic(entity);
+                continue;
+            }
+            flag =true;
+        }
+        dao.updateFalt(workStaffBasicInfo.getId());
+        return flag;
+    }
+    public void querys(WorkStaffBasicInfo workStaffBasicInfo) {
+        SimpleDateFormat dateFormat1 = new SimpleDateFormat("yyyy-MM-dd");
+        if(workStaffBasicInfo==null|| StringUtils.isBlank(workStaffBasicInfo.getId())){
+            return;
+        }
+        WorkStaffTitle entity = new WorkStaffTitle();
+        entity.setStaffId(workStaffBasicInfo.getId());
+        List<WorkStaffTitle> list=this.findList(entity);
+        List<WorkStaffTitle> newList=Lists.newArrayList();
+        if(list!=null&&list.size()>0){//修改
+            for(WorkStaffTitle workStaffTitle:list){
+                Class<? extends WorkStaffTitle> newClass = workStaffTitle.getClass();
+                Field[] declaredFields = newClass.getDeclaredFields();
+                for (Field field : declaredFields) {
+                    String name = field.getName();
+                    if("name".equals(name)||"grade".equals(name)||"startDate".equals(name)||"pathway".equals(name)||"approvalAuthority".equals(name)
+                            || "startDate".equals(name)||"filePath".equals(name)||"fileName".equals(name)){
+                        String setMethod = "set"+name.substring(0,1).toUpperCase()+name.substring(1);
+                        String getMethod = "get"+name.substring(0,1).toUpperCase()+name.substring(1);
+                        WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+                        workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+                        workStaffAchivesLog.setModule("职称");
+                        workStaffAchivesLog.setSonId(workStaffTitle.getId());
+                        workStaffAchivesLog.setFields(name);
+                        workStaffAchivesLog.setType("修改");
+                        workStaffAchivesLog.setState("1");
+                        List<WorkStaffAchivesLog> logs=workStaffAchivesLogService.findList(workStaffAchivesLog);
+                        try {
+                            Object newInvoke = newClass.getMethod(getMethod).invoke(workStaffTitle);//修改后
+                            if(newInvoke instanceof String){
+                                Method setReadOnly = workStaffTitle.getClass().getMethod(setMethod, String.class);
+                                if(logs!=null&&logs.size()>0){
+                                    setReadOnly.invoke(workStaffTitle,logs.get(0).getNewKey());
+                                }
+                            }
+                            if(newInvoke instanceof Date){//日期
+                                Method setReadOnly = workStaffTitle.getClass().getMethod(setMethod, Date.class);
+                                if(logs!=null&&logs.size()>0){
+                                    Date myDate = dateFormat1.parse(logs.get(0).getNewKey());
+                                    setReadOnly.invoke(workStaffTitle,myDate);
+                                }
+                            }
+                        } catch (NoSuchMethodException e) {
+                            e.printStackTrace();
+                        } catch (IllegalAccessException e) {
+                            e.printStackTrace();
+                        } catch (InvocationTargetException e) {
+                            e.printStackTrace();
+                        } catch (ParseException e) {
+                            e.printStackTrace();
+                        }
+                    }
+                }
+                newList.add(workStaffTitle);
+            }
+        }
+        //新增
+        WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+        workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+        workStaffAchivesLog.setModule("职称");
+        workStaffAchivesLog.setType("新增");
+        workStaffAchivesLog.setState("1");
+        List<WorkStaffAchivesLog> sonIds=workStaffAchivesLogService.findSonId(workStaffAchivesLog);
+        if(sonIds!=null&&sonIds.size()>0){
+            for(WorkStaffAchivesLog w:sonIds){
+                workStaffAchivesLog.setSonId(w.getSonId());
+                WorkStaffTitle workStaffTitle = new WorkStaffTitle();
+                workStaffTitle.setId(w.getSonId());
+                workStaffTitle.setDelFlag("0");
+                workStaffTitle.setStaffId(workStaffBasicInfo.getId());
+                Class<? extends WorkStaffTitle> newClass = workStaffTitle.getClass();
+                Field[] declaredFields = newClass.getDeclaredFields();
+                for (Field field : declaredFields) {
+                    String name = field.getName();
+                    if("name".equals(name)||"grade".equals(name)||"startDate".equals(name)||"pathway".equals(name)||"approvalAuthority".equals(name)
+                            || "startDate".equals(name)||"filePath".equals(name)||"fileName".equals(name)){
+                        String setMethod = "set"+name.substring(0,1).toUpperCase()+name.substring(1);
+                        String getMethod = "get"+name.substring(0,1).toUpperCase()+name.substring(1);
+                        workStaffAchivesLog.setFields(name);
+                        List<WorkStaffAchivesLog> logs=workStaffAchivesLogService.findList(workStaffAchivesLog);
+                        try {
+                            if("startDate".equals(name)){//日期
+                                Method setReadOnly = workStaffTitle.getClass().getMethod(setMethod, Date.class);
+                                if(logs!=null&&logs.size()>0){
+                                    Date myDate = dateFormat1.parse(logs.get(0).getNewKey());
+                                    setReadOnly.invoke(workStaffTitle,myDate);
+                                }
+                            }else{
+                                Method setReadOnly = workStaffTitle.getClass().getMethod(setMethod, String.class);
+                                if(logs!=null&&logs.size()>0){
+                                    setReadOnly.invoke(workStaffTitle,logs.get(0).getNewKey());
+                                }
+                            }
+                        } catch (NoSuchMethodException e) {
+                            e.printStackTrace();
+                        } catch (IllegalAccessException e) {
+                            e.printStackTrace();
+                        } catch (InvocationTargetException e) {
+                            e.printStackTrace();
+                        } catch (ParseException e) {
+                            e.printStackTrace();
+                        }
+                    }
+                }
+                newList.add(workStaffTitle);
+            }
+        }
+        //删除
+        WorkStaffAchivesLog delLog=new WorkStaffAchivesLog();
+        delLog.setStaffId(workStaffBasicInfo.getId());
+        delLog.setModule("职称");
+        delLog.setType("删除");
+        workStaffAchivesLog.setState("1");
+        List<WorkStaffAchivesLog> dellogs=workStaffAchivesLogService.findList(delLog);
+        if(dellogs!=null&&dellogs.size()>0){
+            for(WorkStaffAchivesLog w:dellogs){
+                newList.remove(dao.get(w.getSonId()));
+            }
+        }
+        workStaffBasicInfo.setTitleList(newList);
+    }
+
+    @Transactional(readOnly = false)
+    public void saveEdu(WorkStaffBasicInfo workStaffBasicInfo) {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        List<WorkStaffTitle> titleList =workStaffBasicInfo.getTitleList();
+        if(titleList!=null&&titleList.size()>0){
+            for(WorkStaffTitle newTitle:titleList){
+                Class<? extends WorkStaffTitle> newClass = newTitle.getClass();
+                Field[] declaredFields = newClass.getDeclaredFields();
+                if(newTitle.getId()!=null&&!"1".equals(newTitle.getDelFlag())&&!"".equals(newTitle.getId())){
+                    if(newTitle.getFile()!=null&&!newTitle.getFile().isEmpty()&&newTitle.getFile().getSize()>0){
+                        MultipartFile file = newTitle.getFile();
+                        newTitle.setFilePath(this.uploadFile(file,newTitle.getFilePath()));
+                    }
+                    WorkStaffTitle oldTitle=this.get(newTitle.getId());
+                    if(oldTitle!=null){
+                        Class<? extends WorkStaffTitle> oldClass = oldTitle.getClass();
+                        for (Field field : declaredFields) {
+                            String name = field.getName();
+                            if("name".equals(name)||"grade".equals(name)||"startDate".equals(name)||"pathway".equals(name)||"approvalAuthority".equals(name)
+                                    || "startDate".equals(name)||"filePath".equals(name)||"fileName".equals(name)){
+                                String methodName = "get"+name.substring(0,1).toUpperCase()+name.substring(1);
+                                WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+                                workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+                                workStaffAchivesLog.setModule("职称");
+                                workStaffAchivesLog.setSonId(newTitle.getId());
+                                workStaffAchivesLog.setFields(name);
+                                workStaffAchivesLog.setState("1");
+                                try {
+                                    Object newInvoke = newClass.getMethod(methodName).invoke(newTitle);//修改后
+                                    Object oldInvoke = oldClass.getMethod(methodName).invoke(oldTitle);//修改前
+                                    String describes=EDU_MAP.get(name);
+                                    if(newInvoke instanceof String){
+                                        String newValue=newInvoke.toString();
+                                        String oldValue=oldInvoke.toString();
+                                        if(!newValue.equals(oldValue)){
+                                                workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                                        "职称",describes,name,
+                                                        oldInvoke.toString(),newInvoke.toString(),
+                                                        oldInvoke.toString(),newInvoke.toString(),newTitle.getId(),"修改");
+
+                                        }
+                                    }
+                                    if(newInvoke instanceof Date){//日期
+                                        String newDate="";
+                                        String oldDate="";
+                                        if(newInvoke!=null){
+                                            newDate=sdf.format(newInvoke);
+                                        }
+                                        if (oldInvoke!=null){
+                                            oldDate=sdf.format(oldInvoke);
+                                        }
+                                        if(!newDate.equals(oldDate)){
+                                            workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                                    "职称",describes,name,
+                                                    oldDate,newDate,oldDate,newDate,newTitle.getId(),"修改");
+                                        }
+                                    }
+                                } catch (NoSuchMethodException e) {
+                                    e.printStackTrace();
+                                } catch (IllegalAccessException e) {
+                                    e.printStackTrace();
+                                } catch (InvocationTargetException e) {
+                                    e.printStackTrace();
+                                }
+                            }
+                        }
+
+                    }
+                }else if((newTitle.getId()==null||"".equals(newTitle.getId()))&&"0".equals(newTitle.getDelFlag())){//新增
+                    if(newTitle.getFile()!=null&&!newTitle.getFile().isEmpty()&&newTitle.getFile().getSize()>0){
+                        MultipartFile file = newTitle.getFile();
+                        newTitle.setFilePath(this.uploadFile(file,newTitle.getFilePath()));
+                    }
+                    String newId=IdGen.uuid();
+                    for (Field field : declaredFields) {
+                        String name = field.getName();
+                        if("name".equals(name)||"grade".equals(name)||"startDate".equals(name)||"pathway".equals(name)||"approvalAuthority".equals(name)
+                                || "startDate".equals(name)||"filePath".equals(name)||"fileName".equals(name)){
+                            String methodName = "get"+name.substring(0,1).toUpperCase()+name.substring(1);
+                            WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+                            workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+                            workStaffAchivesLog.setModule("职称");
+                            workStaffAchivesLog.setSonId(newId);
+                            workStaffAchivesLog.setFields(name);
+                            workStaffAchivesLog.setState("1");
+                            try {
+                                Object newInvoke = newClass.getMethod(methodName).invoke(newTitle);//修改后
+                                String describes=EDU_MAP.get(name);
+                                if(newInvoke instanceof String){
+                                    String newValue=newInvoke.toString();
+                                        workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                                "职称",describes,name,
+                                                "",newInvoke.toString(),
+                                                "",newInvoke.toString(),newId,"新增");
+
+                                }
+                                if(newInvoke instanceof Date){//日期
+                                    String newDate=sdf.format(newInvoke);
+                                    workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                            "职称",describes,name,
+                                            "",newDate,"",newDate,newId,"新增");
+                                };
+                            } catch (NoSuchMethodException e) {
+                                e.printStackTrace();
+                            } catch (IllegalAccessException e) {
+                                e.printStackTrace();
+                            } catch (InvocationTargetException e) {
+                                e.printStackTrace();
+                            }
+                        }
+                    }
+                }else if(newTitle.getId()!=null&&"1".equals(newTitle.getDelFlag())&&!"".equals(newTitle.getId())){//删除
+                    WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+                    workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+                    workStaffAchivesLog.setModule("职称");
+                    workStaffAchivesLog.setSonId(newTitle.getId());
+                    workStaffAchivesLog.setType("删除");
+                    workStaffAchivesLog.setState("1");
+                    workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                            "职称","","",
+                            "","",
+                            "","",newTitle.getId(),"删除");
+                }
+            }
+        }
+    }
+}

+ 449 - 0
src/main/java/com/jeeplus/modules/workstaff/service/WorkStaffTrainingService.java

@@ -0,0 +1,449 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workstaff.service;
+
+import java.io.InputStream;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.jeeplus.common.bos.BOSClientUtil;
+import com.jeeplus.common.config.Global;
+import com.jeeplus.common.oss.OSSClientUtil;
+import com.jeeplus.common.utils.DateUtils;
+import com.jeeplus.common.utils.IdGen;
+import com.jeeplus.common.utils.StringUtils;
+import com.jeeplus.modules.sys.dao.UserDao;
+import com.jeeplus.modules.sys.entity.User;
+import com.jeeplus.modules.sys.utils.DictUtils;
+import com.jeeplus.modules.workstaff.entity.WorkStaffBasicInfo;
+import com.jeeplus.modules.workstaff.entity.WorkStaffEducation;
+import com.jeeplus.modules.workstaffachiveslog.entity.WorkStaffAchivesLog;
+import com.jeeplus.modules.workstaffachiveslog.service.WorkStaffAchivesLogService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.jeeplus.common.persistence.Page;
+import com.jeeplus.common.service.CrudService;
+import com.jeeplus.modules.workstaff.entity.WorkStaffTraining;
+import com.jeeplus.modules.workstaff.dao.WorkStaffTrainingDao;
+import org.springframework.web.multipart.MultipartFile;
+
+/**
+ * 培训经历Service
+ * @author ssrh
+ * @version 2018-07-27
+ */
+@Service
+@Transactional(readOnly = true)
+public class WorkStaffTrainingService extends CrudService<WorkStaffTrainingDao, WorkStaffTraining> {
+    @Autowired
+    private WorkStaffAchivesLogService workStaffAchivesLogService;
+    @Autowired
+    private UserDao userDao;
+	public WorkStaffTraining get(String id) {
+		return super.get(id);
+	}
+	
+	public List<WorkStaffTraining> findList(WorkStaffTraining workStaffTraining) {
+		return super.findList(workStaffTraining);
+	}
+	
+	public Page<WorkStaffTraining> findPage(Page<WorkStaffTraining> page, WorkStaffTraining workStaffTraining) {
+		return super.findPage(page, workStaffTraining);
+	}
+	
+	@Transactional(readOnly = false)
+	public void save(WorkStaffTraining workStaffTraining) {
+		super.save(workStaffTraining);
+	}
+	
+	@Transactional(readOnly = false)
+	public void delete(WorkStaffTraining workStaffTraining) {
+		super.delete(workStaffTraining);
+	}
+
+
+    public boolean save(WorkStaffBasicInfo workStaffBasicInfo,boolean first) {
+        if(workStaffBasicInfo==null|| StringUtils.isBlank(workStaffBasicInfo.getId())){
+            return false;
+        }
+        List<WorkStaffTraining> list = workStaffBasicInfo.getTrainingList();
+        if(list==null||list.size()<=0){
+            return false;
+        }
+        boolean flag=false;
+        for (WorkStaffTraining entity : list) {
+            if(entity!=null&&"1".equals(entity.getDelFlag())&&StringUtils.isBlank(entity.getId())){
+                continue;
+            }
+            if(entity!=null&&"1".equals(entity.getDelFlag())){
+                dao.deleteByLogic(entity);
+                continue;
+            }
+            if (entity!=null){
+                if(entity.getFile()!=null&&!entity.getFile().isEmpty()&&entity.getFile().getSize()>0){
+                    MultipartFile file = entity.getFile();
+                    entity.setFileName(file.getOriginalFilename());
+                    entity.setFilePath(this.uploadFile(file,entity.getFilePath()));
+                }
+                entity.setStaff(workStaffBasicInfo.getId());
+                this.save(entity);
+                if(first){
+                    entity.setId(null);
+                    entity.setFilePath("");
+                }
+                flag = true;
+            }
+        }
+        return flag;
+    }
+
+    public String uploadFile(MultipartFile file, String filePath){
+        String date = DateUtils.formatDate(new Date(),"yyMMddHHmm");
+        try {
+            if (file != null && file.getSize() > 0) {
+                String path = new StringBuilder("/employeeInfo/").append(date)
+                        .append(file.getOriginalFilename()).toString();
+                InputStream inputStream = file.getInputStream();
+                BOSClientUtil bosClientUtil = new BOSClientUtil();
+                String url = bosClientUtil.upload(path, inputStream);
+                return url;
+            }
+        }catch (Exception e){
+            logger.error("上传文件失败!");
+        }
+        return null;
+    }
+
+    public void query(WorkStaffBasicInfo workStaffBasicInfo) {
+        if(workStaffBasicInfo==null|| StringUtils.isBlank(workStaffBasicInfo.getId())){
+            return;
+        }
+        WorkStaffTraining entity = new WorkStaffTraining();
+        entity.setStaff(workStaffBasicInfo.getId());
+        workStaffBasicInfo.setTrainingList(this.findList(entity));
+    }
+
+    private static Map<String,String> EDU_MAP = Maps.newHashMap();//教育经历
+
+    static{//教育经历
+        EDU_MAP.put("name", "培训名称");
+        EDU_MAP.put("agency", "培训机构");
+        EDU_MAP.put("address", "培训地点");
+        EDU_MAP.put("startDate", "培训起始日期");
+        EDU_MAP.put("endDate", "培训终止日期");
+        EDU_MAP.put("type", "培训类型");
+        EDU_MAP.put("hours", "学时");
+        EDU_MAP.put("certificate", "所获证书");
+        EDU_MAP.put("filePath", "文件");
+        EDU_MAP.put("fileName", "文件名");
+        EDU_MAP.put("remarks", "备注");
+    }
+    public boolean saveApply(WorkStaffBasicInfo workStaffBasicInfo,boolean first) {
+        if(workStaffBasicInfo==null|| StringUtils.isBlank(workStaffBasicInfo.getId())){
+            return false;
+        }
+        List<WorkStaffTraining> list = workStaffBasicInfo.getTrainingList();
+        if(list==null||list.size()<=0){
+            return false;
+        }
+        boolean flag = false;
+        User u=userDao.get(workStaffBasicInfo.getUserId());
+        for (WorkStaffTraining entity : list) {
+            entity.setStaff(workStaffBasicInfo.getId());
+            WorkStaffTraining workStaffTraining=dao.get(entity.getId());
+            if(workStaffTraining==null){
+                entity.setCreateBy(u);
+                entity.setCreateDate(new Date());
+                entity.setUpdateBy(u);
+                entity.setUpdateDate(new Date());
+                dao.insert(entity);
+            }else{
+                this.save(entity);
+            }
+            if(entity!=null&&"1".equals(entity.getDelFlag())){
+                dao.deleteByLogic(entity);
+                continue;
+            }
+            flag =true;
+        }
+        dao.updateFalt(workStaffBasicInfo.getId());
+        return flag;
+    }
+
+    public void querys(WorkStaffBasicInfo workStaffBasicInfo) {
+        SimpleDateFormat dateFormat1 = new SimpleDateFormat("yyyy-MM-dd");
+        if(workStaffBasicInfo==null|| StringUtils.isBlank(workStaffBasicInfo.getId())){
+            return;
+        }
+        WorkStaffTraining entity = new WorkStaffTraining();
+        entity.setStaff(workStaffBasicInfo.getId());
+        List<WorkStaffTraining> list=this.findList(entity);
+        List<WorkStaffTraining> newList=Lists.newArrayList();
+        if(list!=null&&list.size()>0){//修改
+            for(WorkStaffTraining workStaffTraining:list){
+                Class<? extends WorkStaffTraining> newClass = workStaffTraining.getClass();
+                Field[] declaredFields = newClass.getDeclaredFields();
+                for (Field field : declaredFields) {
+                    String name = field.getName();
+                    if("name".equals(name)||"agency".equals(name)||"address".equals(name)||"startDate".equals(name)||"endDate".equals(name)
+                            || "type".equals(name)||"hours".equals(name)||"certificate".equals(name)||"filePath".equals(name)
+                            ||"fileName".equals(name)||"remarks".equals(name)){
+                        String setMethod = "set"+name.substring(0,1).toUpperCase()+name.substring(1);
+                        String getMethod = "get"+name.substring(0,1).toUpperCase()+name.substring(1);
+                        WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+                        workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+                        workStaffAchivesLog.setModule("培训经历");
+                        workStaffAchivesLog.setSonId(workStaffTraining.getId());
+                        workStaffAchivesLog.setFields(name);
+                        workStaffAchivesLog.setType("修改");
+                        workStaffAchivesLog.setState("1");
+                        List<WorkStaffAchivesLog> logs=workStaffAchivesLogService.findList(workStaffAchivesLog);
+                        try {
+                            Object newInvoke = newClass.getMethod(getMethod).invoke(workStaffTraining);//修改后
+                            if(newInvoke instanceof String){
+                                Method setReadOnly = workStaffTraining.getClass().getMethod(setMethod, String.class);
+                                if(logs!=null&&logs.size()>0){
+                                    setReadOnly.invoke(workStaffTraining,logs.get(0).getNewKey());
+                                }
+                            }
+                            if(newInvoke instanceof Date){//日期
+                                Method setReadOnly = workStaffTraining.getClass().getMethod(setMethod, Date.class);
+                                if(logs!=null&&logs.size()>0){
+                                    Date myDate = dateFormat1.parse(logs.get(0).getNewKey());
+                                    setReadOnly.invoke(workStaffTraining,myDate);
+                                }
+                            }
+                        } catch (NoSuchMethodException e) {
+                            e.printStackTrace();
+                        } catch (IllegalAccessException e) {
+                            e.printStackTrace();
+                        } catch (InvocationTargetException e) {
+                            e.printStackTrace();
+                        } catch (ParseException e) {
+                            e.printStackTrace();
+                        }
+                    }
+                }
+                newList.add(workStaffTraining);
+            }
+        }
+        //新增
+        WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+        workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+        workStaffAchivesLog.setModule("培训经历");
+        workStaffAchivesLog.setType("新增");
+        workStaffAchivesLog.setState("1");
+        List<WorkStaffAchivesLog> sonIds=workStaffAchivesLogService.findSonId(workStaffAchivesLog);
+        if(sonIds!=null&&sonIds.size()>0){
+            for(WorkStaffAchivesLog w:sonIds){
+                workStaffAchivesLog.setSonId(w.getSonId());
+                WorkStaffTraining workStaffTraining = new WorkStaffTraining();
+                workStaffTraining.setId(w.getSonId());
+                workStaffTraining.setDelFlag("0");
+                workStaffTraining.setStaff(workStaffBasicInfo.getId());
+                Class<? extends WorkStaffTraining> newClass = workStaffTraining.getClass();
+                Field[] declaredFields = newClass.getDeclaredFields();
+                for (Field field : declaredFields) {
+                    String name = field.getName();
+                    if("name".equals(name)||"agency".equals(name)||"address".equals(name)||"startDate".equals(name)||"endDate".equals(name)
+                            || "type".equals(name)||"hours".equals(name)||"certificate".equals(name)||"filePath".equals(name)
+                            ||"fileName".equals(name)||"remarks".equals(name)){
+                        String setMethod = "set"+name.substring(0,1).toUpperCase()+name.substring(1);
+                        String getMethod = "get"+name.substring(0,1).toUpperCase()+name.substring(1);
+                        workStaffAchivesLog.setFields(name);
+                        List<WorkStaffAchivesLog> logs=workStaffAchivesLogService.findList(workStaffAchivesLog);
+                        try {
+                            if("startDate".equals(name)||"endDate".equals(name)){//日期
+                                Method setReadOnly = workStaffTraining.getClass().getMethod(setMethod, Date.class);
+                                if(logs!=null&&logs.size()>0){
+                                    Date myDate = dateFormat1.parse(logs.get(0).getNewKey());
+                                    setReadOnly.invoke(workStaffTraining,myDate);
+                                }
+                            }else{
+                                Method setReadOnly = workStaffTraining.getClass().getMethod(setMethod, String.class);
+                                if(logs!=null&&logs.size()>0){
+                                    setReadOnly.invoke(workStaffTraining,logs.get(0).getNewKey());
+                                }
+                            }
+                        } catch (NoSuchMethodException e) {
+                            e.printStackTrace();
+                        } catch (IllegalAccessException e) {
+                            e.printStackTrace();
+                        } catch (InvocationTargetException e) {
+                            e.printStackTrace();
+                        } catch (ParseException e) {
+                            e.printStackTrace();
+                        }
+                    }
+                }
+                newList.add(workStaffTraining);
+            }
+        }
+        //删除
+        WorkStaffAchivesLog delLog=new WorkStaffAchivesLog();
+        delLog.setStaffId(workStaffBasicInfo.getId());
+        delLog.setModule("培训经历");
+        delLog.setType("删除");
+        workStaffAchivesLog.setState("1");
+        List<WorkStaffAchivesLog> dellogs=workStaffAchivesLogService.findList(delLog);
+        if(dellogs!=null&&dellogs.size()>0){
+            for(WorkStaffAchivesLog w:dellogs){
+                newList.remove(dao.get(w.getSonId()));
+            }
+        }
+        workStaffBasicInfo.setTrainingList(newList);
+    }
+    @Transactional(readOnly = false)
+    public void saveEdu(WorkStaffBasicInfo workStaffBasicInfo) {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        List<WorkStaffTraining> trainingList =workStaffBasicInfo.getTrainingList();
+        if(trainingList!=null&&trainingList.size()>0){
+            for(WorkStaffTraining newTraining:trainingList){
+                Class<? extends WorkStaffTraining> newClass = newTraining.getClass();
+                Field[] declaredFields = newClass.getDeclaredFields();
+                if(newTraining.getId()!=null&&!"1".equals(newTraining.getDelFlag())&&!"".equals(newTraining.getId())){
+                    if(newTraining.getFile()!=null&&!newTraining.getFile().isEmpty()&&newTraining.getFile().getSize()>0){
+                        MultipartFile file = newTraining.getFile();
+                        newTraining.setFilePath(this.uploadFile(file,newTraining.getFilePath()));
+                    }
+                    WorkStaffTraining oldTraining=this.get(newTraining.getId());
+                    if(oldTraining!=null){
+                        Class<? extends WorkStaffTraining> oldClass = oldTraining.getClass();
+                        for (Field field : declaredFields) {
+                            String name = field.getName();
+                            if("name".equals(name)||"agency".equals(name)||"address".equals(name)||"startDate".equals(name)||"endDate".equals(name)
+                                    || "type".equals(name)||"hours".equals(name)||"certificate".equals(name)||"filePath".equals(name)
+                                    ||"fileName".equals(name)||"remarks".equals(name)){
+                                String methodName = "get"+name.substring(0,1).toUpperCase()+name.substring(1);
+                                WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+                                workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+                                workStaffAchivesLog.setModule("培训经历");
+                                workStaffAchivesLog.setSonId(newTraining.getId());
+                                workStaffAchivesLog.setFields(name);
+                                workStaffAchivesLog.setState("1");
+                                try {
+                                    Object newInvoke = newClass.getMethod(methodName).invoke(newTraining);//修改后
+                                    Object oldInvoke = oldClass.getMethod(methodName).invoke(oldTraining);//修改前
+                                    String describes=EDU_MAP.get(name);
+                                    if(newInvoke instanceof String){
+                                        String newValue=newInvoke.toString();
+                                        String oldValue=oldInvoke.toString();
+                                        if(!newValue.equals(oldValue)){
+                                            if("type".equals(name)){
+                                                workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                                        "培训经历",describes,name,
+                                                        DictUtils.getMainDictLabel(oldValue,"training_type",""),
+                                                        DictUtils.getMainDictLabel(newValue,"training_type",""),
+                                                        oldValue,newValue,newTraining.getId(),"修改");
+                                            }else{
+                                                workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                                        "培训经历",describes,name,
+                                                        oldInvoke.toString(),newInvoke.toString(),
+                                                        oldInvoke.toString(),newInvoke.toString(),newTraining.getId(),"修改");
+                                            }
+                                        }
+                                    }
+                                    if(newInvoke instanceof Date){//日期
+                                        String newDate="";
+                                        String oldDate="";
+                                        if(newInvoke!=null){
+                                            newDate=sdf.format(newInvoke);
+                                        }
+                                        if (oldInvoke!=null){
+                                            oldDate=sdf.format(oldInvoke);
+                                        }
+                                        if(!newDate.equals(oldDate)){
+                                            workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                                    "培训经历",describes,name,
+                                                    oldDate,newDate,oldDate,newDate,newTraining.getId(),"修改");
+                                        }
+                                    }
+                                } catch (NoSuchMethodException e) {
+                                    e.printStackTrace();
+                                } catch (IllegalAccessException e) {
+                                    e.printStackTrace();
+                                } catch (InvocationTargetException e) {
+                                    e.printStackTrace();
+                                }
+                            }
+                        }
+
+                    }
+                }else if((newTraining.getId()==null||"".equals(newTraining.getId()))&&"0".equals(newTraining.getDelFlag())){//新增
+                    if(newTraining.getFile()!=null&&!newTraining.getFile().isEmpty()&&newTraining.getFile().getSize()>0){
+                        MultipartFile file = newTraining.getFile();
+                        newTraining.setFilePath(this.uploadFile(file,newTraining.getFilePath()));
+                    }
+                    String newId=IdGen.uuid();
+                    for (Field field : declaredFields) {
+                        String name = field.getName();
+                        if("name".equals(name)||"agency".equals(name)||"address".equals(name)||"startDate".equals(name)||"endDate".equals(name)
+                                || "type".equals(name)||"hours".equals(name)||"certificate".equals(name)||"filePath".equals(name)
+                                ||"fileName".equals(name)||"remarks".equals(name)){
+                            String methodName = "get"+name.substring(0,1).toUpperCase()+name.substring(1);
+                            WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+                            workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+                            workStaffAchivesLog.setModule("培训经历");
+                            workStaffAchivesLog.setSonId(newId);
+                            workStaffAchivesLog.setFields(name);
+                            workStaffAchivesLog.setState("1");
+                            try {
+                                Object newInvoke = newClass.getMethod(methodName).invoke(newTraining);//修改后
+                                String describes=EDU_MAP.get(name);
+                                if(newInvoke instanceof String){
+                                    String newValue=newInvoke.toString();
+                                    if("type".equals(name)){
+                                        workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                                "培训经历",describes,name,
+                                                "",
+                                                DictUtils.getMainDictLabel(newValue,"training_type",""),
+                                                "",newValue,newId,"新增");
+                                    }else{
+                                        workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                                "培训经历",describes,name,
+                                                "",newInvoke.toString(),
+                                                "",newInvoke.toString(),newId,"新增");
+                                    }
+                                }
+                                if(newInvoke instanceof Date){//日期
+                                    String newDate=sdf.format(newInvoke);
+                                    workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                                            "培训经历",describes,name,
+                                            "",newDate,"",newDate,newId,"新增");
+                                };
+                            } catch (NoSuchMethodException e) {
+                                e.printStackTrace();
+                            } catch (IllegalAccessException e) {
+                                e.printStackTrace();
+                            } catch (InvocationTargetException e) {
+                                e.printStackTrace();
+                            }
+                        }
+                    }
+                }else if(newTraining.getId()!=null&&"1".equals(newTraining.getDelFlag())&&!"".equals(newTraining.getId())){//删除
+                    WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+                    workStaffAchivesLog.setStaffId(workStaffBasicInfo.getId());
+                    workStaffAchivesLog.setModule("培训经历");
+                    workStaffAchivesLog.setSonId(newTraining.getId());
+                    workStaffAchivesLog.setType("删除");
+                    workStaffAchivesLog.setState("1");
+                    workStaffAchivesLogService.saveStaffLog(workStaffAchivesLog,workStaffBasicInfo.getId(),
+                            "培训经历","","",
+                            "","",
+                            "","",newTraining.getId(),"删除");
+                }
+            }
+        }
+    }
+}

+ 736 - 0
src/main/java/com/jeeplus/modules/workstaff/web/WorkStaffBasicInfoController.java

@@ -0,0 +1,736 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workstaff.web;
+
+import java.io.*;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.net.URLDecoder;
+import java.net.URLEncoder;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.validation.ConstraintViolationException;
+
+import com.google.common.collect.Maps;
+import com.jeeplus.common.bos.BOSClientUtil;
+import com.jeeplus.common.json.AjaxJson;
+import com.jeeplus.common.oss.OSSClientUtil;
+import com.jeeplus.common.utils.FileUtils;
+import com.jeeplus.modules.sys.entity.Area;
+import com.jeeplus.modules.sys.entity.Role;
+import com.jeeplus.modules.sys.service.RoleService;
+import com.jeeplus.modules.sys.utils.DictUtils;
+import com.jeeplus.modules.sys.utils.UserUtils;
+import com.jeeplus.modules.sysimportinfo.entity.SysImportInfo;
+import com.jeeplus.modules.sysimportinfo.service.SysImportInfoService;
+import com.jeeplus.modules.wexinpackage.access.entity.AccessToken;
+import com.jeeplus.modules.wexinpackage.access.entity.WeChatUser;
+import com.jeeplus.modules.wexinpackage.access.util.access.AccessTokenUtil;
+import com.jeeplus.modules.wexinpackage.access.util.access.AddressBookUtil;
+import com.jeeplus.modules.wexinpackage.access.util.access.WeChatParamsUtil;
+import com.jeeplus.modules.workprojectnotify.entity.WorkProjectNotify;
+import com.jeeplus.modules.workprojectnotify.service.WorkProjectNotifyService;
+import com.jeeplus.modules.workrelationship.entity.WorkRelationship;
+import com.jeeplus.modules.workstaff.entity.WorkStaffRewards;
+import com.jeeplus.modules.workstaffachiveslog.dao.WorkStaffAchivesLogDao;
+import com.jeeplus.modules.workstaffachiveslog.entity.WorkStaffAchivesLog;
+import com.jeeplus.modules.workstaffachiveslog.service.WorkStaffAchivesLogService;
+import net.sf.json.JSONObject;
+import netscape.security.UserTarget;
+import org.apache.shiro.authz.annotation.Logical;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.MultipartHttpServletRequest;
+import org.springframework.web.multipart.commons.CommonsMultipartResolver;
+import org.springframework.web.servlet.mvc.support.RedirectAttributes;
+
+import com.google.common.collect.Lists;
+import com.jeeplus.common.utils.DateUtils;
+import com.jeeplus.common.utils.MyBeanUtils;
+import com.jeeplus.common.config.Global;
+import com.jeeplus.common.persistence.Page;
+import com.jeeplus.common.web.BaseController;
+import com.jeeplus.common.utils.StringUtils;
+import com.jeeplus.common.utils.excel.ExportExcel;
+import com.jeeplus.common.utils.excel.ImportExcel;
+import com.jeeplus.modules.workstaff.entity.WorkStaffBasicInfo;
+import com.jeeplus.modules.workstaff.service.WorkStaffBasicInfoService;
+
+/**
+ * 员工基本信息Controller
+ * @author ssrh
+ * @version 2018-07-26
+ */
+@Controller
+@RequestMapping(value = "${adminPath}/workstaff/workStaffBasicInfo")
+public class WorkStaffBasicInfoController extends BaseController {
+
+	@Autowired
+	private WorkStaffBasicInfoService workStaffBasicInfoService;
+	@Autowired
+	private WorkStaffAchivesLogService workStaffAchivesLogService;
+	@Autowired
+	private WorkStaffAchivesLogDao workStaffAchivesLogDao;
+	@Autowired
+	private WorkProjectNotifyService workProjectNotifyService;
+    @Autowired
+    private SysImportInfoService sysImportInfoService;
+    @Autowired
+    private  RoleService roleService;
+
+	@ModelAttribute
+	public WorkStaffBasicInfo get(@RequestParam(required=false) String id) {
+		WorkStaffBasicInfo entity = null;
+		if (StringUtils.isNotBlank(id)){
+			entity = workStaffBasicInfoService.get(id);
+		}
+		if (entity == null){
+			entity = new WorkStaffBasicInfo();
+			entity.setId(id);
+		}
+		return entity;
+	}
+	
+	/**
+	 * 员工信息列表页面
+	 */
+	@RequiresPermissions("workstaff:workStaffBasicInfo:list")
+	@RequestMapping(value = {"list", ""})
+	public String list(WorkStaffBasicInfo workStaffBasicInfo, HttpServletRequest request, HttpServletResponse response, Model model) {
+		Page<WorkStaffBasicInfo> page = workStaffBasicInfoService.findPage(new Page<WorkStaffBasicInfo>(request, response), workStaffBasicInfo); 
+		model.addAttribute("page", page);
+		return "modules/workstaff/workStaffBasicInfoList";
+	}
+
+	/**
+	 * 查看,增加,编辑员工信息表单页面
+	 */
+	@RequiresPermissions(value={"workstaff:workStaffBasicInfo:add","workstaff:workStaffBasicInfo:edit"},logical=Logical.OR)
+	@RequestMapping(value = "form")
+	public String form(WorkStaffBasicInfo workStaffBasicInfo, Model model,boolean reFlag) {
+        if(StringUtils.isBlank(workStaffBasicInfo.getId())&&StringUtils.isNotBlank(workStaffBasicInfo.getAchiveId())) {
+            workStaffBasicInfo = workStaffBasicInfoService.getByAchiveId(workStaffBasicInfo);
+        }
+		if(StringUtils.isNotBlank(workStaffBasicInfo.getId())){
+		    workStaffBasicInfoService.queryDetails(workStaffBasicInfo);
+        }else {
+		    workStaffBasicInfo.setTs("0");
+		    workStaffBasicInfo.setPolitics("普通居民");
+		    workStaffBasicInfo.setExSoldier("0");
+		    workStaffBasicInfo.setMarriage("未婚");
+		    workStaffBasicInfo.setNation(DictUtils.getDictValue("汉族","nation_type",""));
+        }
+        workStaffBasicInfo.setRoleId(roleService.getRoleIdByUserId(workStaffBasicInfo.getUserId()));
+		if(StringUtils.isNotBlank(workStaffBasicInfo.getId())){
+			model.addAttribute("updateFlag","1");
+		}
+        model.addAttribute("workStaffBasicInfo", workStaffBasicInfo);
+        String view = "modules/workstaff/workStaffBasicInfoForm";
+        if(UserUtils.getUser().getId().equals(workStaffBasicInfo.getUserId())){
+            view = "modules/workstaff/workStaffBasicDetailForm";
+        }
+		return view;
+	}
+
+	/**
+	 * 查看,增加,编辑员工信息表单页面
+	 */
+	@RequiresPermissions(value={"workstaff:workStaffAchiveInfo:add","workstaff:workStaffAchiveInfo:edit"},logical=Logical.OR)
+	@RequestMapping(value = "achiveForm")
+	public String achiveForm(WorkStaffBasicInfo workStaffBasicInfo, Model model,boolean reFlag) {
+        workStaffBasicInfo = workStaffBasicInfoService.getAchive(workStaffBasicInfo);
+		if(StringUtils.isNotBlank(workStaffBasicInfo.getId())){
+		    workStaffBasicInfoService.queryDetails(workStaffBasicInfo);
+        }
+        model.addAttribute("workStaffBasicInfo", workStaffBasicInfo);
+		return "modules/workstaff/workStaffAchiveInfoForm";
+	}
+	//人员信息库用
+	@RequiresPermissions(value={"workstaff:workStaffAchiveInfo:add","workstaff:workStaffAchiveInfo:edit"},logical=Logical.OR)
+	@RequestMapping(value = "achiveForms")
+	public String achiveForms(WorkStaffBasicInfo workStaffBasicInfo, Model model,boolean reFlag) {
+		workStaffBasicInfo = workStaffBasicInfoService.getAchive(workStaffBasicInfo);
+		if(StringUtils.isNotBlank(workStaffBasicInfo.getId())){
+			workStaffBasicInfoService.queryDetails(workStaffBasicInfo);
+		}
+		model.addAttribute("workStaffBasicInfo", workStaffBasicInfo);
+		return "modules/workstaff/workStaffAchiveInfoForms";
+	}
+    /**
+     * 查看,增加,编辑员工信息表单页面
+     */
+    @RequiresPermissions(value={"workstaff:workStaffBasicInfo:add","workstaff:workStaffBasicInfo:edit"},logical=Logical.OR)
+    @RequestMapping(value = "reform")
+    public String reform(WorkStaffBasicInfo workStaffBasicInfo, Model model) {
+        workStaffBasicInfo = workStaffBasicInfoService.queryAchive(workStaffBasicInfo);
+        workStaffBasicInfoService.queryDetails(workStaffBasicInfo);
+        if(StringUtils.isNotBlank(workStaffBasicInfo.getAchiveId())&&!workStaffBasicInfo.getId().equals(workStaffBasicInfo.getAchiveId())) {
+            //读取当前分公司劳务信息
+            workStaffBasicInfo.setId(workStaffBasicInfo.getAchiveId());
+            workStaffBasicInfoService.queryRelationShips(workStaffBasicInfo);
+        }else if(StringUtils.isBlank(workStaffBasicInfo.getAchiveId())){
+            //当前分公司没有档案记录
+            workStaffBasicInfo.setLabourList(new ArrayList<WorkRelationship>());
+        }
+        workStaffBasicInfo.setId(null);
+        workStaffBasicInfo.setOffice(null);
+        workStaffBasicInfo.setJobGrade(null);
+        workStaffBasicInfo.setSalary(null);
+        workStaffBasicInfo.setStatus(null);
+        workStaffBasicInfo.setEntryDate(null);
+        workStaffBasicInfo.setDimissionDate(null);
+        workStaffBasicInfo.setWorkEndDate(null);
+        model.addAttribute("workStaffBasicInfo", workStaffBasicInfo);
+        return "modules/workstaff/workStaffBasicInfoForm";
+    }
+
+	/**
+	 * 查看,增加,编辑员工信息表单页面
+	 */
+	@RequestMapping(value = "view")
+	public String view(WorkStaffBasicInfo workStaffBasicInfo, Model model,boolean reFlag) {
+		if(StringUtils.isNotBlank(workStaffBasicInfo.getId())){
+            workStaffBasicInfoService.queryDetails(workStaffBasicInfo);
+        }
+		Role role = roleService.get(roleService.getRoleIdByUserId(workStaffBasicInfo.getUserId()));
+		workStaffBasicInfo.setRoleId(role.getId());
+		workStaffBasicInfo.setRoleName(role.getName());
+		model.addAttribute("workStaffBasicInfo", workStaffBasicInfo);
+		return "modules/workstaff/workStaffBasicInfoView";
+	}
+
+	@RequestMapping(value = "addressbookview")
+	public String addressbookview(WorkStaffBasicInfo workStaffBasicInfo, Model model,boolean reFlag) {
+//		if(StringUtils.isNotBlank(workStaffBasicInfo.getId())){
+//			workStaffBasicInfoService.queryDetails(workStaffBasicInfo);
+//		}
+		Role role = roleService.get(roleService.getRoleIdByUserId(workStaffBasicInfo.getUserId()));
+		workStaffBasicInfo.setRoleId(role.getId());
+		workStaffBasicInfo.setRoleName(role.getName());
+		model.addAttribute("workStaffBasicInfo", workStaffBasicInfo);
+		return "modules/workstaff/workAddressBookView";
+	}
+
+	/**
+	 * 查看,增加,编辑员工信息表单页面
+	 */
+	@RequestMapping(value = "achiveView")
+	public String achiveView(WorkStaffBasicInfo workStaffBasicInfo, Model model,boolean reFlag) {
+        workStaffBasicInfo = workStaffBasicInfoService.getAchive(workStaffBasicInfo);
+        workStaffBasicInfo.setAchiveId(workStaffBasicInfo.getId());
+		if(StringUtils.isNotBlank(workStaffBasicInfo.getId())){
+            workStaffBasicInfoService.queryDetails(workStaffBasicInfo);
+        }
+        model.addAttribute("workStaffBasicInfo", workStaffBasicInfo);
+		return "modules/workstaff/workStaffBasicInfoView";
+	}
+
+	/**
+	 * 保存员工信息
+	 */
+	@RequestMapping(value = "save")
+	public String save(WorkStaffBasicInfo workStaffBasicInfo, Model model, RedirectAttributes redirectAttributes,HttpServletRequest request) throws Exception{
+		if (!beanValidator(model, workStaffBasicInfo)){
+			return form(workStaffBasicInfo, model,false);
+		}
+		MultipartFile pictureFile = workStaffBasicInfo.getPictureFile();
+		if(pictureFile != null && pictureFile.getSize()>0){
+			String path = new StringBuilder("/employeeImg/")
+			.append(workStaffBasicInfo.getName()+System.currentTimeMillis()).append(".png").toString();
+			InputStream inputStream = pictureFile.getInputStream();
+            BOSClientUtil bosClientUtil = new BOSClientUtil();
+			String url = bosClientUtil.upload(path, inputStream);
+            workStaffBasicInfo.setPicture(url);
+		}else{
+			workStaffBasicInfo.setPicture("");
+		}
+
+		if(!workStaffBasicInfo.getIsNewRecord()){//编辑表单保存
+			WorkStaffBasicInfo t = workStaffBasicInfoService.get(workStaffBasicInfo.getId());//从数据库取出记录的值
+			MyBeanUtils.copyBeanNotNull2Bean(workStaffBasicInfo, t);//将编辑表单中的非NULL值覆盖数据库记录中的值
+			workStaffBasicInfoService.save(t,request);//保存
+			String accessToken = AccessTokenUtil. getAccessToken(WeChatParamsUtil.corpId, WeChatParamsUtil.contactsSecret);
+			WeChatUser weChatUser = AddressBookUtil.replaceUser(workStaffBasicInfo);
+			AddressBookUtil.updateUser(accessToken,weChatUser);
+		}else{//新增表单保存
+			workStaffBasicInfoService.save(workStaffBasicInfo,request);//保存
+			String accessToken = AccessTokenUtil. getAccessToken(WeChatParamsUtil.corpId, WeChatParamsUtil.contactsSecret);
+			WeChatUser weChatUser = AddressBookUtil.replaceUser(workStaffBasicInfo);
+			AddressBookUtil.createUser(accessToken,weChatUser);
+		}
+		addMessage(redirectAttributes, "保存员工信息成功");
+        if (StringUtils.isNotBlank(workStaffBasicInfo.getHome()) && "home".equals(workStaffBasicInfo.getHome())){
+            return "redirect:" + Global.getAdminPath() + "/home/?repage";
+        }
+		return "redirect:"+Global.getAdminPath()+"/workstaff/workStaffBasicInfo/?repage";
+	}
+
+	/**
+	 * 保存员工信息
+	 */
+	@RequestMapping(value = "saveAchive")
+	public String saveAchive(WorkStaffBasicInfo workStaffBasicInfo, Model model, RedirectAttributes redirectAttributes,HttpServletRequest request) throws Exception{
+		if (!beanValidator(model, workStaffBasicInfo)){
+			return form(workStaffBasicInfo, model,false);
+		}
+		if(!workStaffBasicInfo.getIsNewRecord()){//编辑表单保存
+            WorkStaffBasicInfo select = new WorkStaffBasicInfo();
+            select.setAchiveId(workStaffBasicInfo.getId());
+			WorkStaffBasicInfo t = workStaffBasicInfoService.getAchive(select);//从数据库取出记录的值
+			MyBeanUtils.copyBeanNotNull2Bean(workStaffBasicInfo, t);//将编辑表单中的非NULL值覆盖数据库记录中的值
+			workStaffBasicInfoService.saveAchive(t,request);//保存
+		}else{//新增表单保存
+			workStaffBasicInfoService.saveAchive(workStaffBasicInfo,request);//保存
+		}
+		addMessage(redirectAttributes, "保存员工档案信息成功");
+        if (StringUtils.isNotBlank(workStaffBasicInfo.getHome()) && "home".equals(workStaffBasicInfo.getHome())){
+            return "redirect:" + Global.getAdminPath() + "/home/?repage";
+        }
+		return "redirect:"+Global.getAdminPath()+"/workstaff/workStaffBasicInfo/achivelist?repage";
+	}
+	//人员信息库用
+	@RequestMapping(value = "saveAchives")
+	public String saveAchives(WorkStaffBasicInfo workStaffBasicInfo, Model model, RedirectAttributes redirectAttributes,HttpServletRequest request) throws Exception{
+		if (!beanValidator(model, workStaffBasicInfo)){
+			return form(workStaffBasicInfo, model,false);
+		}
+		if(!workStaffBasicInfo.getIsNewRecord()){//编辑表单保存
+			WorkStaffBasicInfo select = new WorkStaffBasicInfo();
+			select.setAchiveId(workStaffBasicInfo.getId());
+			WorkStaffBasicInfo t = workStaffBasicInfoService.getAchive(select);//从数据库取出记录的值
+			MyBeanUtils.copyBeanNotNull2Bean(workStaffBasicInfo, t);//将编辑表单中的非NULL值覆盖数据库记录中的值
+			workStaffBasicInfoService.saveAchive(t,request);//保存
+		}else{//新增表单保存
+			workStaffBasicInfoService.saveAchive(workStaffBasicInfo,request);//保存
+		}
+		addMessage(redirectAttributes, "保存员工档案信息成功");
+		if (StringUtils.isNotBlank(workStaffBasicInfo.getHome()) && "home".equals(workStaffBasicInfo.getHome())){
+			return "redirect:" + Global.getAdminPath() + "/home/?repage";
+		}
+		return "redirect:"+Global.getAdminPath()+"/workperson/workPerson/list?repage";
+	}
+	/**
+	 * 删除员工信息
+	 */
+	@RequiresPermissions("workstaff:workStaffBasicInfo:del")
+	@RequestMapping(value = "delete")
+	public String delete(WorkStaffBasicInfo workStaffBasicInfo, RedirectAttributes redirectAttributes) {
+		workStaffBasicInfoService.delete(workStaffBasicInfo);
+		AddressBookUtil.deleteUser(AccessTokenUtil.getAccessToken(WeChatParamsUtil.corpId,WeChatParamsUtil.contactsSecret),workStaffBasicInfo.getNo());
+		addMessage(redirectAttributes, "删除员工信息成功");
+		return "redirect:"+Global.getAdminPath()+"/workstaff/workStaffBasicInfo/?repage";
+	}
+	
+	/**
+	 * 批量删除员工信息
+	 */
+	@RequiresPermissions("workstaff:workStaffBasicInfo:del")
+	@RequestMapping(value = "deleteAll")
+	public String deleteAll(String ids, RedirectAttributes redirectAttributes) {
+		String idArray[] =ids.split(",");
+		for(String id : idArray){
+			workStaffBasicInfoService.delete(workStaffBasicInfoService.get(id));
+		}
+		addMessage(redirectAttributes, "删除员工信息成功");
+		return "redirect:"+Global.getAdminPath()+"/workstaff/workStaffBasicInfo/?repage";
+	}
+	
+	/**
+	 * 导出excel文件
+	 */
+	@RequiresPermissions("workstaff:workStaffBasicInfo:achiveExport")
+    @RequestMapping(value = "exportAchive", method=RequestMethod.POST)
+    public String exportFile(WorkStaffBasicInfo workStaffBasicInfo, HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) {
+		try {
+            String fileName = "员工信息"+DateUtils.getDate("yyyyMMddHHmmss")+".xlsx";
+            Page<WorkStaffBasicInfo> page = workStaffBasicInfoService.findAchivePage(new Page<WorkStaffBasicInfo>(request, response, -1), workStaffBasicInfo);
+    		new ExportExcel(true,"员工信息", WorkStaffBasicInfo.class,1).setDataList(page.getList()).write(response, fileName).dispose();
+            addMessage(redirectAttributes, "导出员工信息记录成功!");
+    		return null;
+		} catch (Exception e) {
+			addMessage(redirectAttributes, "导出员工信息记录失败!失败信息:"+e.getMessage());
+		}
+		return "redirect:"+Global.getAdminPath()+"/workstaff/workStaffBasicInfo/achivelist?repage";
+    }
+
+	/**
+	 * 导入Excel数据
+	 */
+	@RequiresPermissions("workstaff:workStaffBasicInfo:achiveImport")
+    @RequestMapping(value = "importAchive", method=RequestMethod.POST)
+    public String importFile(MultipartFile file, RedirectAttributes redirectAttributes,HttpServletRequest request) {
+		try {
+			int successNum = 0;
+			int failureNum = 0;
+			String userName = UserUtils.getUser().getName();
+            String date = DateUtils.getDate("yyyyMMddHHmmss");
+			StringBuilder failureMsg = new StringBuilder();
+			ImportExcel ei = new ImportExcel(file, 1, 0);
+			List<WorkStaffBasicInfo> list = ei.getDataList(WorkStaffBasicInfo.class);
+            List<WorkStaffBasicInfo> errlist = new ArrayList<>();
+			for (WorkStaffBasicInfo workStaffBasicInfo : list){
+				try{
+				    StringBuilder errInfo = new StringBuilder();
+				    if(workStaffBasicInfoService.validateStaff(workStaffBasicInfo,errInfo)) {
+                        workStaffBasicInfoService.saveAchive(workStaffBasicInfo, request);
+                        successNum++;
+                    }else {
+				        failureNum++;
+				        workStaffBasicInfo.setNowDate(date);
+				        workStaffBasicInfo.setErrInfo(errInfo.toString());
+				        workStaffBasicInfo.setUserName(userName);
+				        errlist.add(workStaffBasicInfo);
+                    }
+				}catch (Exception ex) {
+				    logger.error("解析导入数据失败:",ex);
+					failureNum++;
+                    workStaffBasicInfo.setNowDate(date);
+                    workStaffBasicInfo.setErrInfo(ex.getMessage());
+                    workStaffBasicInfo.setUserName(userName);
+                    errlist.add(workStaffBasicInfo);
+				}
+			}
+
+            SysImportInfo sysImportInfo = new SysImportInfo();
+            sysImportInfo.setCompanyId(UserUtils.getSelectCompany().getId());
+            sysImportInfo.setOfficeId(UserUtils.getSelectOffice().getId());
+            sysImportInfo.setModular("人员档案");
+            if (failureNum>0){
+                failureMsg.insert(0, ",失败 "+failureNum+" 个错误信息记录。");
+                ExportExcel exportExcel= new ExportExcel(false,"员工信息", WorkStaffBasicInfo.class, 1).setDataList(errlist);
+                OSSClientUtil ossUtil = new OSSClientUtil();
+
+                String fileName=date+"人员档案信息错误导入日志.xlsx";
+                String fileDir = "importInfo/workStaffBasicInfoImport/";
+                fileDir = fileDir+System.nanoTime()+"/";
+                try {
+                    ByteArrayOutputStream os = new ByteArrayOutputStream();
+                    exportExcel.write(os);
+                    byte[] content = os.toByteArray();
+                    InputStream inputStream = new ByteArrayInputStream(content);
+                    ossUtil.uploadFile2OSS(inputStream,fileDir, fileName);
+                }catch (Exception e1){
+                    logger.error("人员档案信息错误导入日志文件上传失败!",e1);
+                }
+
+                String name = Global.getAliyunUrl()+"/"+fileDir+fileName;
+                logger.info("name:"+name);
+                sysImportInfo.setUrl(name);
+                sysImportInfo.setFileName(fileName);
+                sysImportInfo.setErrCount(failureNum+"");
+                sysImportInfo.setIsTrue("0");
+            }else {
+                sysImportInfo.setIsTrue("1");
+                sysImportInfo.setErrCount("0");
+            }
+            String info = "已成功导入 "+successNum+" 条人员档案信息记录,失败 "+failureNum+" 个错误信息记录。";
+            sysImportInfo.setErrInfo(info);
+            sysImportInfoService.save(sysImportInfo);
+
+			addMessage(redirectAttributes, "已成功导入 "+successNum+" 条人员档案信息记录"+failureMsg);
+		} catch (Exception e) {
+		    logger.error("导入人员档案信息失败!",e);
+			addMessage(redirectAttributes, "导入人员档案信息失败!失败信息:"+e.getMessage());
+		}
+		return "redirect:"+Global.getAdminPath()+"/workstaff/workStaffBasicInfo/achivelist?repage";
+    }
+	
+	/**
+	 * 下载导入员工信息数据模板
+	 */
+	@RequiresPermissions("workstaff:workStaffBasicInfo:achiveImport")
+    @RequestMapping(value = "importAchive/template")
+    public String importFileTemplate(HttpServletResponse response, RedirectAttributes redirectAttributes) {
+		try {
+            String fileName = "员工档案信息导入模板.xlsx";
+    		List<WorkStaffBasicInfo> list = Lists.newArrayList(); 
+    		new ExportExcel(true,"员工档案信息", WorkStaffBasicInfo.class, 2).setDataList(list).write(response, fileName).dispose();
+    		return null;
+		} catch (Exception e) {
+			addMessage(redirectAttributes, "导入模板下载失败!失败信息:"+e.getMessage());
+		}
+		return "redirect:"+Global.getAdminPath()+"/workstaff/workStaffBasicInfo/achivelist?repage";
+    }
+
+    @RequestMapping("idCard")
+    @ResponseBody
+	public AjaxJson idCard(String idCard){
+	    AjaxJson ajaxJson = new AjaxJson();
+	    WorkStaffBasicInfo obj = workStaffBasicInfoService.findByIdCardAndCom(idCard);
+	    if(obj==null){
+	        ajaxJson.getBody().put("exist",false);
+        }else {
+	        ajaxJson.getBody().put("exist",true);
+            ajaxJson.getBody().put("id",obj.getId());
+            if("离职".equals(obj.getStatus())||"退休".equals(obj.getStatus())){
+	            ajaxJson.getBody().put("onJob",false);
+            }else {
+                ajaxJson.getBody().put("onJob",true);
+            }
+        }
+	    return ajaxJson;
+    }
+
+    /**
+     * 员工档案列表页面
+     */
+    @RequiresPermissions("workstaff:workStaffBasicInfo:achivelist")
+    @RequestMapping(value = {"achivelist"})
+    public String achivelist(WorkStaffBasicInfo workStaffBasicInfo, HttpServletRequest request, HttpServletResponse response, Model model) {
+        Page<WorkStaffBasicInfo> page = workStaffBasicInfoService.findAchivePage(new Page<WorkStaffBasicInfo>(request, response), workStaffBasicInfo);
+        model.addAttribute("page", page);
+        return "modules/workstaff/workStaffAchivesList";
+    }
+
+    /**
+     * 批量删除员工信息
+     */
+    @RequiresPermissions("workstaff:workStaffBasicInfo:achivelist")
+    @RequestMapping(value = "complete")
+    public String complete(String achiveIds, RedirectAttributes redirectAttributes) {
+        workStaffBasicInfoService.complete(achiveIds);
+        addMessage(redirectAttributes, "通知员工成功");
+        return "redirect:"+Global.getAdminPath()+"/workstaff/workStaffBasicInfo/achivelist?repage";
+    }
+
+	@RequestMapping(value = "applyEdit")
+	public String applyEdit(Model model) {
+		WorkStaffBasicInfo workStaffBasicInfo=new WorkStaffBasicInfo();
+		workStaffBasicInfo.setAchiveId(UserUtils.getBasicInfo().getId());
+		workStaffBasicInfo = workStaffBasicInfoService.getAchive(workStaffBasicInfo);
+		workStaffBasicInfo.setAchiveId(workStaffBasicInfo.getId());
+		if(StringUtils.isNotBlank(workStaffBasicInfo.getId())){
+			workStaffBasicInfoService.queryDetails(workStaffBasicInfo);
+		}
+		workStaffBasicInfo.setHome("home");
+		model.addAttribute("workStaffBasicInfo", workStaffBasicInfo);
+		return "modules/workstaff/workStaffBasicDetailModify";
+	}
+
+	@RequestMapping(value = "applyEditDirectly")
+	public String applyEditDirectly(Model model) {
+		WorkStaffBasicInfo workStaffBasicInfo=new WorkStaffBasicInfo();
+		workStaffBasicInfo.setAchiveId(UserUtils.getBasicInfo().getId());
+		workStaffBasicInfo = workStaffBasicInfoService.getAchive(workStaffBasicInfo);
+		workStaffBasicInfo.setAchiveId(workStaffBasicInfo.getId());
+		Role role = roleService.getRoleByUserId(workStaffBasicInfo.getUserId());
+		workStaffBasicInfo.setRoleId(role.getId());
+		workStaffBasicInfo.setRoleName(role.getName());
+		if(StringUtils.isNotBlank(workStaffBasicInfo.getId())){
+			workStaffBasicInfoService.queryDetails(workStaffBasicInfo);
+		}
+		workStaffBasicInfo.setHome("home");
+		model.addAttribute("workStaffBasicInfo", workStaffBasicInfo);
+		return "modules/workstaff/workStaffBasicDetailModifyDirectly";
+	}
+
+	/**
+	 * 保存员工信息
+	 */
+	@RequestMapping(value = "saveAchiveBack")
+	public String saveAchiveBack(WorkStaffBasicInfo workStaffBasicInfo, Model model, RedirectAttributes redirectAttributes,HttpServletRequest request) throws Exception{
+		if (!beanValidator(model, workStaffBasicInfo)){
+			return form(workStaffBasicInfo, model,false);
+		}
+		if (StringUtils.isNotBlank(workStaffBasicInfo.getHome()) && "home".equals(workStaffBasicInfo.getHome())){
+			WorkProjectNotify workProjectNotify = new WorkProjectNotify();
+			workProjectNotify.setNotifyId(workStaffBasicInfo.getId());
+			workProjectNotifyService.readByNotifyId(workProjectNotify);
+		}
+		if (workStaffBasicInfo.getPictureFile() == null || workStaffBasicInfo.getPictureFile().getSize() < 0) {
+			workStaffBasicInfo.setPicture("");
+		}
+		workStaffBasicInfoService.completeApply(workStaffBasicInfo.getId());
+		workStaffBasicInfoService.saveLog(workStaffBasicInfo);
+		addMessage(redirectAttributes, "申请员工档案信息成功");
+		return "redirect:" + Global.getAdminPath() + "/home/?repage";
+	}
+
+	/**
+	 * 保存员工信息
+	 */
+	@RequestMapping(value = "saveAchiveModify")
+	public String saveAchiveModify(WorkStaffBasicInfo workStaffBasicInfo, Model model, RedirectAttributes redirectAttributes,HttpServletRequest request) throws Exception{
+		if (!beanValidator(model, workStaffBasicInfo)){
+			return form(workStaffBasicInfo, model,false);
+		}
+		if (StringUtils.isNotBlank(workStaffBasicInfo.getHome()) && "home".equals(workStaffBasicInfo.getHome())){
+			WorkProjectNotify workProjectNotify = new WorkProjectNotify();
+			workProjectNotify.setNotifyId(workStaffBasicInfo.getId());
+			workProjectNotifyService.readByNotifyId(workProjectNotify);
+		}
+		workStaffBasicInfoService.completeApply(workStaffBasicInfo.getId());
+		workStaffBasicInfoService.saveLog(workStaffBasicInfo);
+		addMessage(redirectAttributes, "申请员工档案信息成功");
+		return "redirect:"+Global.getAdminPath()+"/sys/user/info?repage";
+	}
+
+	/**
+	 * 我的信息-直接修改员工信息
+	 */
+	@RequestMapping(value = "saveAchiveModifyDirectly")
+	public String saveAchiveModifyDirectly(WorkStaffBasicInfo workStaffBasicInfo, Model model, RedirectAttributes redirectAttributes,HttpServletRequest request) throws Exception{
+		if (!beanValidator(model, workStaffBasicInfo)){
+			return form(workStaffBasicInfo, model,false);
+		}
+        MultipartFile pictureFile = workStaffBasicInfo.getPictureFile();
+        if(pictureFile != null && pictureFile.getSize()>0){
+            String path = new StringBuilder("/employeeImg/")
+                    .append(workStaffBasicInfo.getName()+System.currentTimeMillis()).append(".png").toString();
+            InputStream inputStream = pictureFile.getInputStream();
+            BOSClientUtil bosClientUtil = new BOSClientUtil();
+            String url = bosClientUtil.upload(path, inputStream);
+            workStaffBasicInfo.setPicture(url);
+        }
+
+		String achieveId = workStaffBasicInfo.getId();
+		WorkStaffBasicInfo t = workStaffBasicInfoService.getBasicInfoByAchiveId(workStaffBasicInfo.getId());//从数据库取出记录的值
+		String staffId = t.getId();
+		MyBeanUtils.copyBeanNotNull2Bean(workStaffBasicInfo, t);//将编辑表单中的非NULL值覆盖数据库记录中的值
+		t.setAchiveId(achieveId);
+		t.setId(staffId);
+		workStaffBasicInfoService.updateAchieveDirectly(t,request);
+		addMessage(redirectAttributes, "保存员工档案信息成功");
+
+		return "redirect:"+Global.getAdminPath()+"/sys/user/info?repage";
+	}
+
+	@RequestMapping("getChange")
+	@ResponseBody
+	public WorkStaffAchivesLog
+	getChange(String name,String achiveId) throws ParseException {
+		Map<String,String> map=new HashMap<>();
+		WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+		workStaffAchivesLog.setStaffId(achiveId);
+		workStaffAchivesLog.setModule("基本信息");
+		workStaffAchivesLog.setFields(name);
+		workStaffAchivesLog.setState("1");
+		String value="";
+		WorkStaffAchivesLog log=new WorkStaffAchivesLog();
+		if(name!=null&&!name.equals("")){
+			List<WorkStaffAchivesLog> logs=workStaffAchivesLogService.findList(workStaffAchivesLog);
+			if(logs!=null&&logs.size()>0){
+				log.setNewValue(logs.get(0).getNewValue());
+				log.setNewKey(logs.get(0).getNewKey());
+			}
+		}
+		return  log;
+	}
+	@RequestMapping("getEdu")
+	@ResponseBody
+	public boolean getEdu(String id,String achiveId,String module) throws ParseException {
+		boolean falt=false;
+		WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+		workStaffAchivesLog.setStaffId(achiveId);
+		workStaffAchivesLog.setModule(module);
+		workStaffAchivesLog.setSonId(id);
+		workStaffAchivesLog.setState("1");
+		List<WorkStaffAchivesLog> logs=workStaffAchivesLogService.findList(workStaffAchivesLog);
+			if(logs!=null&&logs.size()>0){
+				falt=true;
+			}
+		return  falt;
+	}
+	@RequestMapping("getApply")
+	@ResponseBody
+	public boolean getApply() throws ParseException {
+		boolean falt=false;
+		WorkStaffAchivesLog workStaffAchivesLog=new WorkStaffAchivesLog();
+		workStaffAchivesLog.setStaffId(UserUtils.getBasicInfo().getId());
+		workStaffAchivesLog.setState("1");
+		List<WorkStaffAchivesLog> logs=workStaffAchivesLogService.findList(workStaffAchivesLog);
+		if(logs!=null&&logs.size()>0){
+			falt=true;
+		}
+		return  falt;
+	}
+	/**
+	 * 保存员工信息
+	 */
+	@RequestMapping(value = "pass")
+	public String pass(WorkStaffBasicInfo workStaffBasicInfo, Model model, RedirectAttributes redirectAttributes,HttpServletRequest request) throws Exception{
+		if (!beanValidator(model, workStaffBasicInfo)){
+			return form(workStaffBasicInfo, model,false);
+		}
+		WorkStaffBasicInfo basicInfo = workStaffBasicInfoService.getBasicInfoByAchiveId(workStaffBasicInfo.getId());
+		WorkStaffBasicInfo select = new WorkStaffBasicInfo();
+		select.setAchiveId(workStaffBasicInfo.getId());
+		WorkStaffBasicInfo t = workStaffBasicInfoService.getAchive(select);//从数据库取出记录的值
+		MyBeanUtils.copyBeanNotNull2Bean(workStaffBasicInfo, t);//将编辑表单中的非NULL值覆盖数据库记录中的值
+		workStaffBasicInfoService.saveAchiveApply(t, request);//保存
+		t.setId(basicInfo.getId());
+		workStaffBasicInfoService.save(t);
+		addMessage(redirectAttributes, "保存员工档案信息成功");
+		return "redirect:" + Global.getAdminPath() + "/home/?repage";
+	}
+	@RequestMapping(value = "back")
+	public String back(WorkStaffBasicInfo workStaffBasicInfo, Model model, RedirectAttributes redirectAttributes,HttpServletRequest request) throws Exception{
+		if (StringUtils.isNotBlank(workStaffBasicInfo.getHome()) && "home".equals(workStaffBasicInfo.getHome())){
+			WorkProjectNotify workProjectNotify = new WorkProjectNotify();
+			workProjectNotify.setNotifyId(workStaffBasicInfo.getId());
+			workProjectNotifyService.readByNotifyId(workProjectNotify);
+		}
+		workStaffBasicInfoService.complete(workStaffBasicInfo.getId());
+		workStaffAchivesLogDao.deleteBack(workStaffBasicInfo.getId());
+		addMessage(redirectAttributes, "驳回成功");
+		return "redirect:" + Global.getAdminPath() + "/home/?repage";
+	}
+
+    /**
+     * 查看导入客户管理数据信息
+     */
+    //@RequiresPermissions("importInfo:importInfo:importInfoErr")
+    @RequestMapping(value = "importInfoErr")
+    public String importInfoErr(SysImportInfo sysImportInfo,HttpServletRequest request, HttpServletResponse response, Model model) {
+        SysImportInfo importInfo = new SysImportInfo();
+        importInfo.setModular("人员档案");
+        Page<SysImportInfo> page = sysImportInfoService.findPage(new Page<SysImportInfo>(request, response), importInfo);
+        model.addAttribute("page", page);
+        model.addAttribute("modular", "人员档案");
+        return "modules/sysimportinfo/sysimportinfoList";
+    }
+
+	/**
+	 * 手机号验证
+	 */
+	@ResponseBody
+	@RequestMapping(value = "checkMobile")
+	public String checkMoblie(WorkStaffBasicInfo workStaffBasicInfo) {
+		List<WorkStaffBasicInfo> workStaffBasicInfos = workStaffBasicInfoService.findByMob(workStaffBasicInfo);
+		if(workStaffBasicInfos != null && workStaffBasicInfos.size()>0){
+			return "false";
+		}
+		return "true";
+	}
+
+	/**
+	 * 重名跳转
+	 */
+	@RequestMapping(value = "repeatName")
+	public String repeatName(String name,Model model) throws UnsupportedEncodingException {
+		String name1 = URLDecoder.decode(name, "utf8");
+		List<WorkStaffBasicInfo> list = workStaffBasicInfoService.findByName(name1);
+		model.addAttribute("list",list);
+		return "modules/workstaff/infoList";
+	}
+
+	/**
+	 *员工通讯录展示
+	 */
+	@RequiresPermissions("workstaff:workStaffBasicInfo:addressbook")
+	@RequestMapping(value = "addressbook")
+	public String addressBook(WorkStaffBasicInfo workStaffBasicInfo, HttpServletRequest request, HttpServletResponse response, Model model) {
+		Page<WorkStaffBasicInfo> page = workStaffBasicInfoService.findAddressBook(new Page<WorkStaffBasicInfo>(request, response), workStaffBasicInfo);
+		model.addAttribute("page", page);
+		return "modules/workstaff/workAddressBookList";
+	}
+}

+ 24 - 0
src/main/java/com/jeeplus/modules/workstaffachiveslog/dao/WorkStaffAchivesLogDao.java

@@ -0,0 +1,24 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workstaffachiveslog.dao;
+
+import com.jeeplus.common.persistence.CrudDao;
+import com.jeeplus.common.persistence.annotation.MyBatisDao;
+import com.jeeplus.modules.workstaffachiveslog.entity.WorkStaffAchivesLog;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 档案修改日志DAO接口
+ * @author ssrh
+ * @version 2018-10-11
+ */
+@MyBatisDao
+public interface WorkStaffAchivesLogDao extends CrudDao<WorkStaffAchivesLog> {
+    List<WorkStaffAchivesLog> findSonId(WorkStaffAchivesLog workStaffAchivesLog);
+	int updateState(@Param("staffId") String staffId, @Param("applyer") String applyer, @Param("applyDate") Date applyDate);
+    int deleteBack(@Param("staffId") String staffId);
+}

+ 157 - 0
src/main/java/com/jeeplus/modules/workstaffachiveslog/entity/WorkStaffAchivesLog.java

@@ -0,0 +1,157 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workstaffachiveslog.entity;
+
+import java.util.Date;
+import com.fasterxml.jackson.annotation.JsonFormat;
+
+import com.jeeplus.common.persistence.DataEntity;
+import com.jeeplus.common.utils.excel.annotation.ExcelField;
+
+/**
+ * 档案修改日志Entity
+ * @author ssrh
+ * @version 2018-10-11
+ */
+public class WorkStaffAchivesLog extends DataEntity<WorkStaffAchivesLog> {
+	
+	private static final long serialVersionUID = 1L;
+	private String staffId;		// 档案id
+	private String module;		// 所属模块信息
+	private String describes;		// 描述
+	private String fields;		// 属性
+	private String oldValue;		// 修改前
+	private String newValue;		// 修改后
+	private String applyer;		// 审批人
+	private Date applyDate;		// 审批时间
+	private String oldKey;		// 修改前
+	private String newKey;		// 修改后
+	private String sonId;		// 字表数据id
+	private String type;//新增修改删除
+	private String state;//
+
+	public String getState() {
+		return state;
+	}
+
+	public void setState(String state) {
+		this.state = state;
+	}
+
+	public String getSonId() {
+		return sonId;
+	}
+
+	public void setSonId(String sonId) {
+		this.sonId = sonId;
+	}
+
+	public String getType() {
+		return type;
+	}
+
+	public void setType(String type) {
+		this.type = type;
+	}
+
+	public String getOldKey() {
+		return oldKey;
+	}
+
+	public void setOldKey(String oldKey) {
+		this.oldKey = oldKey;
+	}
+
+	public String getNewKey() {
+		return newKey;
+	}
+
+	public void setNewKey(String newKey) {
+		this.newKey = newKey;
+	}
+
+
+	
+	public WorkStaffAchivesLog() {
+		super();
+	}
+
+	public WorkStaffAchivesLog(String id){
+		super(id);
+	}
+
+	@ExcelField(title="档案id", align=2, sort=7)
+	public String getStaffId() {
+		return staffId;
+	}
+
+	public void setStaffId(String staffId) {
+		this.staffId = staffId;
+	}
+	
+	@ExcelField(title="所属模块信息", align=2, sort=8)
+	public String getModule() {
+		return module;
+	}
+
+	public void setModule(String module) {
+		this.module = module;
+	}
+	
+	@ExcelField(title="描述", align=2, sort=9)
+	public String getDescribes() {
+		return describes;
+	}
+
+	public void setDescribes(String describes) {
+		this.describes = describes;
+	}
+	
+	@ExcelField(title="属性", align=2, sort=10)
+	public String getFields() {
+		return fields;
+	}
+
+	public void setFields(String fields) {
+		this.fields = fields;
+	}
+	
+	@ExcelField(title="修改前", align=2, sort=11)
+	public String getOldValue() {
+		return oldValue;
+	}
+
+	public void setOldValue(String oldValue) {
+		this.oldValue = oldValue;
+	}
+	
+	@ExcelField(title="修改后", align=2, sort=12)
+	public String getNewValue() {
+		return newValue;
+	}
+
+	public void setNewValue(String newValue) {
+		this.newValue = newValue;
+	}
+	
+	@ExcelField(title="审批人", align=2, sort=13)
+	public String getApplyer() {
+		return applyer;
+	}
+
+	public void setApplyer(String applyer) {
+		this.applyer = applyer;
+	}
+	
+	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+	@ExcelField(title="审批时间", align=2, sort=14)
+	public Date getApplyDate() {
+		return applyDate;
+	}
+
+	public void setApplyDate(Date applyDate) {
+		this.applyDate = applyDate;
+	}
+	
+}

+ 91 - 0
src/main/java/com/jeeplus/modules/workstaffachiveslog/service/WorkStaffAchivesLogService.java

@@ -0,0 +1,91 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workstaffachiveslog.service;
+
+import java.util.List;
+
+import com.jeeplus.modules.sys.dao.AreaDao;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.jeeplus.common.persistence.Page;
+import com.jeeplus.common.service.CrudService;
+import com.jeeplus.modules.workstaffachiveslog.entity.WorkStaffAchivesLog;
+import com.jeeplus.modules.workstaffachiveslog.dao.WorkStaffAchivesLogDao;
+
+/**
+ * 档案修改日志Service
+ * @author ssrh
+ * @version 2018-10-11
+ */
+@Service
+@Transactional(readOnly = true)
+public class WorkStaffAchivesLogService extends CrudService<WorkStaffAchivesLogDao, WorkStaffAchivesLog> {
+	@Autowired
+	private WorkStaffAchivesLogDao workStaffAchivesLogDao;
+	public WorkStaffAchivesLog get(String id) {
+		return super.get(id);
+	}
+	
+	public List<WorkStaffAchivesLog> findList(WorkStaffAchivesLog workStaffAchivesLog) {
+		return super.findList(workStaffAchivesLog);
+	}
+	
+	public Page<WorkStaffAchivesLog> findPage(Page<WorkStaffAchivesLog> page, WorkStaffAchivesLog workStaffAchivesLog) {
+		return super.findPage(page, workStaffAchivesLog);
+	}
+	public List<WorkStaffAchivesLog> findSonId(WorkStaffAchivesLog workStaffAchivesLog) {
+		return dao.findSonId(workStaffAchivesLog);
+	}
+
+	@Transactional(readOnly = false)
+	public void save(WorkStaffAchivesLog workStaffAchivesLog) {
+		super.save(workStaffAchivesLog);
+	}
+	
+	@Transactional(readOnly = false)
+	public void delete(WorkStaffAchivesLog workStaffAchivesLog) {
+		super.delete(workStaffAchivesLog);
+	}
+
+	@Transactional(readOnly = false)
+	public  void saveStaffLog(WorkStaffAchivesLog workStaffAchivesLog,String staffId,
+							  String module,String describes,String fields,String oldValue,
+							  String newValue,String oldKey,String newKey,String sonId,String type){
+		List<WorkStaffAchivesLog> logs=this.findList(workStaffAchivesLog);
+		if (logs!=null&&logs.size()>0) {
+			workStaffAchivesLog.preUpdate();
+			workStaffAchivesLog.setId(logs.get(0).getId());
+			workStaffAchivesLog.setStaffId(staffId);
+			workStaffAchivesLog.setModule(module);
+			workStaffAchivesLog.setDescribes(describes);
+			workStaffAchivesLog.setFields(fields);
+			workStaffAchivesLog.setOldValue(oldValue);
+			workStaffAchivesLog.setNewValue(newValue);
+			workStaffAchivesLog.setOldKey(oldKey);
+			workStaffAchivesLog.setNewKey(newKey);
+			workStaffAchivesLog.setSonId(sonId);
+			workStaffAchivesLog.setType(type);
+			workStaffAchivesLog.setState("1");
+			workStaffAchivesLogDao.update(workStaffAchivesLog);
+		} else {
+			workStaffAchivesLog.preInsert();
+			workStaffAchivesLog.setStaffId(staffId);
+			workStaffAchivesLog.setModule(module);
+			workStaffAchivesLog.setDescribes(describes);
+			workStaffAchivesLog.setFields(fields);
+			workStaffAchivesLog.setOldValue(oldValue);
+			workStaffAchivesLog.setNewValue(newValue);
+			workStaffAchivesLog.setOldKey(oldKey);
+			workStaffAchivesLog.setNewKey(newKey);
+			workStaffAchivesLog.setSonId(sonId);
+			workStaffAchivesLog.setType(type);
+			workStaffAchivesLog.setState("1");
+			workStaffAchivesLogDao.insert(workStaffAchivesLog);
+		}
+	}
+	
+	
+}

+ 196 - 0
src/main/java/com/jeeplus/modules/workstaffachiveslog/web/WorkStaffAchivesLogController.java

@@ -0,0 +1,196 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workstaffachiveslog.web;
+
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.validation.ConstraintViolationException;
+
+import org.apache.shiro.authz.annotation.Logical;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.servlet.mvc.support.RedirectAttributes;
+
+import com.google.common.collect.Lists;
+import com.jeeplus.common.utils.DateUtils;
+import com.jeeplus.common.utils.MyBeanUtils;
+import com.jeeplus.common.config.Global;
+import com.jeeplus.common.persistence.Page;
+import com.jeeplus.common.web.BaseController;
+import com.jeeplus.common.utils.StringUtils;
+import com.jeeplus.common.utils.excel.ExportExcel;
+import com.jeeplus.common.utils.excel.ImportExcel;
+import com.jeeplus.modules.workstaffachiveslog.entity.WorkStaffAchivesLog;
+import com.jeeplus.modules.workstaffachiveslog.service.WorkStaffAchivesLogService;
+
+/**
+ * 档案修改日志Controller
+ * @author ssrh
+ * @version 2018-10-11
+ */
+@Controller
+@RequestMapping(value = "${adminPath}/workstaffachiveslog/workStaffAchivesLog")
+public class WorkStaffAchivesLogController extends BaseController {
+
+	@Autowired
+	private WorkStaffAchivesLogService workStaffAchivesLogService;
+	
+	@ModelAttribute
+	public WorkStaffAchivesLog get(@RequestParam(required=false) String id) {
+		WorkStaffAchivesLog entity = null;
+		if (StringUtils.isNotBlank(id)){
+			entity = workStaffAchivesLogService.get(id);
+		}
+		if (entity == null){
+			entity = new WorkStaffAchivesLog();
+		}
+		return entity;
+	}
+	
+	/**
+	 * 档案修改日志列表页面
+	 */
+	@RequiresPermissions("workstaffachiveslog:workStaffAchivesLog:list")
+	@RequestMapping(value = {"list", ""})
+	public String list(WorkStaffAchivesLog workStaffAchivesLog, HttpServletRequest request, HttpServletResponse response, Model model) {
+		Page<WorkStaffAchivesLog> page = workStaffAchivesLogService.findPage(new Page<WorkStaffAchivesLog>(request, response), workStaffAchivesLog); 
+		model.addAttribute("page", page);
+		return "modules/workstaffachiveslog/workStaffAchivesLogList";
+	}
+
+	/**
+	 * 查看,增加,编辑档案修改日志表单页面
+	 */
+	@RequiresPermissions(value={"workstaffachiveslog:workStaffAchivesLog:view","workstaffachiveslog:workStaffAchivesLog:add","workstaffachiveslog:workStaffAchivesLog:edit"},logical=Logical.OR)
+	@RequestMapping(value = "form")
+	public String form(WorkStaffAchivesLog workStaffAchivesLog, Model model) {
+		model.addAttribute("workStaffAchivesLog", workStaffAchivesLog);
+		return "modules/workstaffachiveslog/workStaffAchivesLogForm";
+	}
+
+	/**
+	 * 保存档案修改日志
+	 */
+	@RequiresPermissions(value={"workstaffachiveslog:workStaffAchivesLog:add","workstaffachiveslog:workStaffAchivesLog:edit"},logical=Logical.OR)
+	@RequestMapping(value = "save")
+	public String save(WorkStaffAchivesLog workStaffAchivesLog, Model model, RedirectAttributes redirectAttributes) throws Exception{
+		if (!beanValidator(model, workStaffAchivesLog)){
+			return form(workStaffAchivesLog, model);
+		}
+		if(!workStaffAchivesLog.getIsNewRecord()){//编辑表单保存
+			WorkStaffAchivesLog t = workStaffAchivesLogService.get(workStaffAchivesLog.getId());//从数据库取出记录的值
+			MyBeanUtils.copyBeanNotNull2Bean(workStaffAchivesLog, t);//将编辑表单中的非NULL值覆盖数据库记录中的值
+			workStaffAchivesLogService.save(t);//保存
+		}else{//新增表单保存
+			workStaffAchivesLogService.save(workStaffAchivesLog);//保存
+		}
+		addMessage(redirectAttributes, "保存档案修改日志成功");
+		return "redirect:"+Global.getAdminPath()+"/workstaffachiveslog/workStaffAchivesLog/?repage";
+	}
+	
+	/**
+	 * 删除档案修改日志
+	 */
+	@RequiresPermissions("workstaffachiveslog:workStaffAchivesLog:del")
+	@RequestMapping(value = "delete")
+	public String delete(WorkStaffAchivesLog workStaffAchivesLog, RedirectAttributes redirectAttributes) {
+		workStaffAchivesLogService.delete(workStaffAchivesLog);
+		addMessage(redirectAttributes, "删除档案修改日志成功");
+		return "redirect:"+Global.getAdminPath()+"/workstaffachiveslog/workStaffAchivesLog/?repage";
+	}
+	
+	/**
+	 * 批量删除档案修改日志
+	 */
+	@RequiresPermissions("workstaffachiveslog:workStaffAchivesLog:del")
+	@RequestMapping(value = "deleteAll")
+	public String deleteAll(String ids, RedirectAttributes redirectAttributes) {
+		String idArray[] =ids.split(",");
+		for(String id : idArray){
+			workStaffAchivesLogService.delete(workStaffAchivesLogService.get(id));
+		}
+		addMessage(redirectAttributes, "删除档案修改日志成功");
+		return "redirect:"+Global.getAdminPath()+"/workstaffachiveslog/workStaffAchivesLog/?repage";
+	}
+	
+	/**
+	 * 导出excel文件
+	 */
+	@RequiresPermissions("workstaffachiveslog:workStaffAchivesLog:export")
+    @RequestMapping(value = "export", method=RequestMethod.POST)
+    public String exportFile(WorkStaffAchivesLog workStaffAchivesLog, HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) {
+		try {
+            String fileName = "档案修改日志"+DateUtils.getDate("yyyyMMddHHmmss")+".xlsx";
+            Page<WorkStaffAchivesLog> page = workStaffAchivesLogService.findPage(new Page<WorkStaffAchivesLog>(request, response, -1), workStaffAchivesLog);
+    		new ExportExcel("档案修改日志", WorkStaffAchivesLog.class).setDataList(page.getList()).write(response, fileName).dispose();
+    		return null;
+		} catch (Exception e) {
+			addMessage(redirectAttributes, "导出档案修改日志记录失败!失败信息:"+e.getMessage());
+		}
+		return "redirect:"+Global.getAdminPath()+"/workstaffachiveslog/workStaffAchivesLog/?repage";
+    }
+
+	/**
+	 * 导入Excel数据
+
+	 */
+	@RequiresPermissions("workstaffachiveslog:workStaffAchivesLog:import")
+    @RequestMapping(value = "import", method=RequestMethod.POST)
+    public String importFile(MultipartFile file, RedirectAttributes redirectAttributes) {
+		try {
+			int successNum = 0;
+			int failureNum = 0;
+			StringBuilder failureMsg = new StringBuilder();
+			ImportExcel ei = new ImportExcel(file, 1, 0);
+			List<WorkStaffAchivesLog> list = ei.getDataList(WorkStaffAchivesLog.class);
+			for (WorkStaffAchivesLog workStaffAchivesLog : list){
+				try{
+					workStaffAchivesLogService.save(workStaffAchivesLog);
+					successNum++;
+				}catch(ConstraintViolationException ex){
+					failureNum++;
+				}catch (Exception ex) {
+					failureNum++;
+				}
+			}
+			if (failureNum>0){
+				failureMsg.insert(0, ",失败 "+failureNum+" 条档案修改日志记录。");
+			}
+			addMessage(redirectAttributes, "已成功导入 "+successNum+" 条档案修改日志记录"+failureMsg);
+		} catch (Exception e) {
+			addMessage(redirectAttributes, "导入档案修改日志失败!失败信息:"+e.getMessage());
+		}
+		return "redirect:"+Global.getAdminPath()+"/workstaffachiveslog/workStaffAchivesLog/?repage";
+    }
+	
+	/**
+	 * 下载导入档案修改日志数据模板
+	 */
+	@RequiresPermissions("workstaffachiveslog:workStaffAchivesLog:import")
+    @RequestMapping(value = "import/template")
+    public String importFileTemplate(HttpServletResponse response, RedirectAttributes redirectAttributes) {
+		try {
+            String fileName = "档案修改日志数据导入模板.xlsx";
+    		List<WorkStaffAchivesLog> list = Lists.newArrayList(); 
+    		new ExportExcel("档案修改日志数据", WorkStaffAchivesLog.class, 1).setDataList(list).write(response, fileName).dispose();
+    		return null;
+		} catch (Exception e) {
+			addMessage(redirectAttributes, "导入模板下载失败!失败信息:"+e.getMessage());
+		}
+		return "redirect:"+Global.getAdminPath()+"/workstaffachiveslog/workStaffAchivesLog/?repage";
+    }
+	
+	
+	
+
+}

+ 30 - 0
src/main/java/com/jeeplus/modules/workstock/dao/WorkStockDao.java

@@ -0,0 +1,30 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workstock.dao;
+
+import com.jeeplus.common.persistence.CrudDao;
+import com.jeeplus.common.persistence.annotation.MyBatisDao;
+import com.jeeplus.modules.workstock.entity.WorkStock;
+
+/**
+ * 物品采购DAO接口
+ * @author lw
+ * @version 2018-07-13
+ */
+@MyBatisDao
+public interface WorkStockDao extends CrudDao<WorkStock> {
+
+    /**
+     * 更新流程实例ID
+     * @return
+     */
+    public int updateProcessInstanceId(WorkStock workStock);
+
+    /**
+     * 根据流程实例ID获取
+     * @param processInstanceId
+     * @return
+     */
+    public WorkStock getByProcessInstanceId(String processInstanceId);
+}

+ 242 - 0
src/main/java/com/jeeplus/modules/workstock/entity/WorkStock.java

@@ -0,0 +1,242 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workstock.entity;
+
+
+import com.google.common.collect.Lists;
+import com.jeeplus.common.persistence.ActEntity;
+import com.jeeplus.common.persistence.DataEntity;
+import com.jeeplus.common.utils.excel.annotation.ExcelField;
+import com.jeeplus.modules.workcatalogueitem.entity.WorkCatalogueItem;
+import com.jeeplus.modules.workcatalogueitemstock.entity.WorkCatalogueItemStock;
+import com.jeeplus.modules.workclientinfo.entity.WorkClientAttachment;
+import com.jeeplus.modules.workitemstock.entity.WorkItemStock;
+import org.activiti.engine.history.HistoricProcessInstance;
+import org.activiti.engine.repository.ProcessDefinition;
+import org.activiti.engine.runtime.ProcessInstance;
+import org.activiti.engine.task.Task;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 物品采购Entity
+ * @author lw
+ * @version 2018-07-13
+ */
+public class WorkStock extends ActEntity<WorkStock> {
+	private static final long serialVersionUID = 1L;
+	//通知类型 61
+	public static final String SERIAL_BIZCODE = "13";
+	private String processInstanceId;		// 流程号
+	private String officeId;		// 部门
+	private String companyId;		// 公司
+	private String status;		// 状态
+	private String number;		// 采购编号
+	private String reason;		// 申请事由
+	private Date acceptDate;		// 验收日期
+	private String acceptName;		// 验收人
+	private String officeName;       //所属部门
+	private String home;       //跳转首页标记
+	private Date beginContractDate;		// 开始
+	private Date endContractDate;		// 结束
+	private List<WorkClientAttachment> workAttachments = Lists.newArrayList();   //106
+	private List<WorkCatalogueItemStock> workCatalogueItemStocks = Lists.newArrayList();  //物品申请列表
+	private List<WorkItemStock> workItemStocks = Lists.newArrayList();  //物品验收列表
+	private List<WorkItemStock> workItemStockAssets = Lists.newArrayList();  //固定资产列表
+	// 流程任务
+	private Task task;
+	private Map<String, Object> variables;
+	// 运行中的流程实例
+	private ProcessInstance processInstance;
+	// 历史的流程实例
+	private HistoricProcessInstance historicProcessInstance;
+	// 流程定义
+	private ProcessDefinition processDefinition;
+	public WorkStock() {
+		super();
+	}
+
+	public WorkStock(String id){
+		super(id);
+	}
+
+	@ExcelField(title="流程号", align=2, sort=7)
+	public String getProcessInstanceId() {
+		return processInstanceId;
+	}
+
+	public void setProcessInstanceId(String processInstanceId) {
+		this.processInstanceId = processInstanceId;
+	}
+	
+	@ExcelField(title="部门", align=2, sort=8)
+	public String getOfficeId() {
+		return officeId;
+	}
+
+	public void setOfficeId(String officeId) {
+		this.officeId = officeId;
+	}
+	
+	@ExcelField(title="公司", align=2, sort=9)
+	public String getCompanyId() {
+		return companyId;
+	}
+
+	public void setCompanyId(String companyId) {
+		this.companyId = companyId;
+	}
+	
+	@ExcelField(title="状态", align=2, sort=10)
+	public String getStatus() {
+		return status;
+	}
+
+	public void setStatus(String status) {
+		this.status = status;
+	}
+	
+	@ExcelField(title="采购编号", align=2, sort=11)
+	public String getNumber() {
+		return number;
+	}
+
+	public void setNumber(String number) {
+		this.number = number;
+	}
+	
+	@ExcelField(title="申请事由", align=2, sort=12)
+	public String getReason() {
+		return reason;
+	}
+
+	public void setReason(String reason) {
+		this.reason = reason;
+	}
+
+	public String getHome() {
+		return home;
+	}
+
+	public void setHome(String home) {
+		this.home = home;
+	}
+
+	public Date getBeginContractDate() {
+		return beginContractDate;
+	}
+
+	public void setBeginContractDate(Date beginContractDate) {
+		this.beginContractDate = beginContractDate;
+	}
+
+	public Date getEndContractDate() {
+		return endContractDate;
+	}
+
+	public void setEndContractDate(Date endContractDate) {
+		this.endContractDate = endContractDate;
+	}
+
+	public String getOfficeName() {
+		return officeName;
+	}
+
+	public void setOfficeName(String officeName) {
+		this.officeName = officeName;
+	}
+
+	public List<WorkClientAttachment> getWorkAttachments() {
+		return workAttachments;
+	}
+
+	public void setWorkAttachments(List<WorkClientAttachment> workAttachments) {
+		this.workAttachments = workAttachments;
+	}
+
+	public List<WorkCatalogueItemStock> getWorkCatalogueItemStocks() {
+		return workCatalogueItemStocks;
+	}
+
+	public void setWorkCatalogueItemStocks(List<WorkCatalogueItemStock> workCatalogueItemStocks) {
+		this.workCatalogueItemStocks = workCatalogueItemStocks;
+	}
+
+	public List<WorkItemStock> getWorkItemStockAssets() {
+		return workItemStockAssets;
+	}
+
+	public void setWorkItemStockAssets(List<WorkItemStock> workItemStockAssets) {
+		this.workItemStockAssets = workItemStockAssets;
+	}
+
+	public List<WorkItemStock> getWorkItemStocks() {
+		return workItemStocks;
+	}
+
+	public void setWorkItemStocks(List<WorkItemStock> workItemStocks) {
+		this.workItemStocks = workItemStocks;
+	}
+
+	public Task getTask() {
+		return task;
+	}
+
+	public void setTask(Task task) {
+		this.task = task;
+	}
+
+	public Map<String, Object> getVariables() {
+		return variables;
+	}
+
+	public void setVariables(Map<String, Object> variables) {
+		this.variables = variables;
+	}
+
+	public ProcessInstance getProcessInstance() {
+		return processInstance;
+	}
+
+	public void setProcessInstance(ProcessInstance processInstance) {
+		this.processInstance = processInstance;
+	}
+
+	public HistoricProcessInstance getHistoricProcessInstance() {
+		return historicProcessInstance;
+	}
+
+	public void setHistoricProcessInstance(HistoricProcessInstance historicProcessInstance) {
+		this.historicProcessInstance = historicProcessInstance;
+	}
+
+	public ProcessDefinition getProcessDefinition() {
+		return processDefinition;
+	}
+
+	public void setProcessDefinition(ProcessDefinition processDefinition) {
+		this.processDefinition = processDefinition;
+	}
+
+	@ExcelField(title="验收日期", align=2, sort=13)
+	public Date getAcceptDate() {
+		return acceptDate;
+	}
+
+	public void setAcceptDate(Date acceptDate) {
+		this.acceptDate = acceptDate;
+	}
+	
+	@ExcelField(title="验收人", align=2, sort=14)
+	public String getAcceptName() {
+		return acceptName;
+	}
+
+	public void setAcceptName(String acceptName) {
+		this.acceptName = acceptName;
+	}
+	
+}

+ 912 - 0
src/main/java/com/jeeplus/modules/workstock/service/WorkStockService.java

@@ -0,0 +1,912 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workstock.service;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.google.common.collect.Maps;
+import com.jeeplus.common.utils.*;
+import com.jeeplus.common.websocket.onchat.ChatServerPool;
+import com.jeeplus.modules.act.service.ActTaskService;
+import com.jeeplus.modules.act.utils.ActUtils;
+import com.jeeplus.modules.serialnum.service.SerialNumTplService;
+import com.jeeplus.modules.sys.entity.Office;
+import com.jeeplus.modules.sys.entity.User;
+import com.jeeplus.modules.sys.utils.UserUtils;
+import com.jeeplus.modules.workactivity.dao.WorkActivityProcessDao;
+import com.jeeplus.modules.workactivity.entity.Activity;
+import com.jeeplus.modules.workactivity.entity.WorkActivityProcess;
+import com.jeeplus.modules.workactivity.service.ActivityService;
+import com.jeeplus.modules.workactivity.service.WorkActivityProcessService;
+import com.jeeplus.modules.workactivitymenu.entity.WorkActivityMenu;
+import com.jeeplus.modules.workactivitymenu.service.WorkActivityMenuService;
+import com.jeeplus.modules.workcatalogueitem.entity.WorkCatalogueItem;
+import com.jeeplus.modules.workcatalogueitemstock.dao.WorkCatalogueItemStockDao;
+import com.jeeplus.modules.workcatalogueitemstock.entity.WorkCatalogueItemStock;
+import com.jeeplus.modules.workcatalogueitemstock.service.WorkCatalogueItemStockService;
+import com.jeeplus.modules.workclientinfo.dao.WorkClientAttachmentDao;
+import com.jeeplus.modules.workclientinfo.entity.WorkClientAttachment;
+import com.jeeplus.modules.workcontractinfo.service.WorkContractInfoService;
+import com.jeeplus.modules.workcontractrecord.dao.WorkContractRecordDao;
+import com.jeeplus.modules.workitem.dao.WorkItemDao;
+import com.jeeplus.modules.workitem.entity.WorkItem;
+import com.jeeplus.modules.workitem.service.WorkItemService;
+import com.jeeplus.modules.workitemstock.dao.WorkItemStockDao;
+import com.jeeplus.modules.workitemstock.entity.WorkItemStock;
+import com.jeeplus.modules.workitemstock.service.WorkItemStockService;
+import com.jeeplus.modules.workprojectnotify.entity.WorkProjectNotify;
+import com.jeeplus.modules.workprojectnotify.service.WorkProjectNotifyService;
+import com.jeeplus.modules.workprojectnotify.util.UtilNotify;
+import com.jeeplus.modules.workreimbursement.entity.WorkAccount;
+import org.activiti.engine.ActivitiObjectNotFoundException;
+import org.activiti.engine.IdentityService;
+import org.activiti.engine.RuntimeService;
+import org.activiti.engine.runtime.ProcessInstance;
+import org.java_websocket.WebSocket;
+import org.apache.commons.beanutils.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.jeeplus.common.persistence.Page;
+import com.jeeplus.common.service.CrudService;
+import com.jeeplus.modules.workstock.entity.WorkStock;
+import com.jeeplus.modules.workstock.dao.WorkStockDao;
+
+/**
+ * 物品采购Service
+ * @author lw
+ * @version 2018-07-13
+ */
+@Service
+@Transactional(readOnly = true)
+public class WorkStockService extends CrudService<WorkStockDao, WorkStock> {
+	@Autowired
+	private WorkClientAttachmentDao workClientAttachmentDao;
+	@Autowired
+	private IdentityService identityService;
+	@Autowired
+	private WorkActivityMenuService workActivityMenuService;
+	@Autowired
+	private WorkProjectNotifyService workProjectNotifyService;
+	@Autowired
+	private RuntimeService runtimeService;
+	@Autowired
+	private WorkActivityProcessService workActivityProcessService;
+	@Autowired
+	private WorkStockDao workStockDao;
+	@Autowired
+	private ActTaskService actTaskService;
+	@Autowired
+	private ActivityService activityService;
+	@Autowired
+	private WorkActivityProcessDao workActivityProcessDao;
+	@Autowired
+	private SerialNumTplService serialNumTplService;
+	@Autowired
+	private WorkCatalogueItemStockDao workCatalogueItemStockDao;
+	@Autowired
+	private WorkItemStockDao workItemStockDao;
+	@Autowired
+	private WorkCatalogueItemStockService workCatalogueItemStockService;
+	@Autowired
+	private WorkItemStockService workItemStockService;
+	@Autowired
+	private WorkItemDao workItemDao;
+	@Autowired
+	private WorkItemService workItemService;
+
+
+	public WorkStock get(String id) {
+		WorkStock workStock = super.get(id);
+		//附件
+		WorkClientAttachment workClientAttachment = new WorkClientAttachment();
+		workClientAttachment.setAttachmentId(id);
+		workClientAttachment.setAttachmentFlag("106");
+		workStock.setWorkAttachments(workClientAttachmentDao.findList(workClientAttachment));
+		if(workStock!=null){
+			WorkCatalogueItemStock workCatalogueItemStock = new WorkCatalogueItemStock();
+			WorkItemStock workItemStock = new WorkItemStock();
+			workCatalogueItemStock.setStockId(workStock.getId());
+			workItemStock.setStockId(workStock.getId());
+			List<WorkCatalogueItemStock> buyDetailsList1 = workCatalogueItemStockService.findList(workCatalogueItemStock);
+			List<WorkItemStock> buyDetailsList2 = workItemStockService.findList(workItemStock);
+			//物品申请列表
+			workStock.setWorkCatalogueItemStocks(buyDetailsList1);
+			//物品验收列表
+			workStock.setWorkItemStocks(buyDetailsList2);
+		}
+		return workStock;
+	}
+	
+	public List<WorkStock> findList(WorkStock workStock) {
+		return super.findList(workStock);
+	}
+	
+	public Page<WorkStock> findPage(Page<WorkStock> page, WorkStock workStock) {
+		workStock.getSqlMap().put("dsf", dataScopeFilter(workStock.getCurrentUser(), "o", "u","s", MenuStatusEnum.WORK_STOCK.getValue()));
+		workStock.setPage(page);
+		page.setList(findList(workStock));
+		return page;
+	}
+	
+	@Transactional(readOnly = false)
+	public void save(WorkStock workStock) {
+		super.save(workStock);
+		updateWorkReimbursementInfo(workStock);
+	}
+	@Transactional(readOnly = false)
+	public void updateWorkReimbursementInfo(WorkStock workStock) {
+		//申请列表
+		for (WorkCatalogueItemStock buyDetails : workStock.getWorkCatalogueItemStocks()){
+			if (buyDetails.getId() == null){
+				continue;
+			}
+			if (buyDetails.DEL_FLAG_NORMAL.equals(buyDetails.getDelFlag())){
+				buyDetails.setStockId(workStock.getId());
+				if(StringUtils.isNotBlank(buyDetails.getType()) && buyDetails.getType().contains(",")){
+					buyDetails.setType(buyDetails.getType().replace(",",""));
+				}
+				if(StringUtils.isNotBlank(buyDetails.getPrimaryUnit()) && buyDetails.getPrimaryUnit().contains(",")){
+					buyDetails.setPrimaryUnit(buyDetails.getPrimaryUnit().replace(",",""));
+				}
+				if(StringUtils.isNotBlank(buyDetails.getName()) && buyDetails.getName().contains(",")){
+					buyDetails.setName(buyDetails.getName().replace(",",""));
+				}
+				if(StringUtils.isNotBlank(buyDetails.getNumber()) && buyDetails.getNumber().contains(",")){
+					buyDetails.setNumber(buyDetails.getNumber().replace(",",""));
+				}
+				if(StringUtils.isNotBlank(buyDetails.getModel()) && buyDetails.getModel().contains(",")){
+					buyDetails.setModel(buyDetails.getModel().replace(",",""));
+				}
+				if (StringUtils.isBlank(buyDetails.getId())){
+					buyDetails.preInsert();
+					workCatalogueItemStockDao.insert(buyDetails);
+				}else{
+					buyDetails.preUpdate();
+					workCatalogueItemStockDao.update(buyDetails);
+				}
+			}else{
+				workCatalogueItemStockDao.delete(buyDetails);
+			}
+		}
+		//验收列表
+		for (WorkItemStock buyDetails : workStock.getWorkItemStocks()){
+			if (buyDetails.getId() == null){
+				continue;
+			}
+			if (buyDetails.DEL_FLAG_NORMAL.equals(buyDetails.getDelFlag())){
+				buyDetails.setStockId(workStock.getId());
+				if (StringUtils.isBlank(buyDetails.getId())){
+					buyDetails.preInsert();
+					workItemStockDao.insert(buyDetails);
+				}else{
+					buyDetails.preUpdate();
+					workItemStockDao.update(buyDetails);
+				}
+			}else{
+				workItemStockDao.delete(buyDetails);
+			}
+		}
+		//固定资产列表
+		for (WorkItemStock buyDetails : workStock.getWorkItemStockAssets()){
+			if (buyDetails.getId() == null){
+				continue;
+			}
+			if (buyDetails.DEL_FLAG_NORMAL.equals(buyDetails.getDelFlag())){
+				if (StringUtils.isBlank(buyDetails.getId())){
+				}else{
+					buyDetails.preUpdate();
+					workItemStockDao.updateNumber(buyDetails);
+				}
+			}
+		}
+		//附件信息
+		for (WorkClientAttachment workClientAttachment : workStock.getWorkAttachments()) {
+			if (workClientAttachment.getId() == null) {
+				continue;
+			}
+			if (WorkClientAttachment.DEL_FLAG_NORMAL.equals(workClientAttachment.getDelFlag())) {
+				workClientAttachment.setAttachmentId(workStock.getId());
+				workClientAttachment.setAttachmentFlag("106");
+				workClientAttachment.setAttachmentUser(UserUtils.getUser().getId());
+				if (StringUtils.isBlank(workClientAttachment.getId()) || "null".equals(workClientAttachment.getId())) {
+					workClientAttachment.preInsert();
+					workClientAttachmentDao.insert(workClientAttachment);
+				} else {
+					workClientAttachment.preUpdate();
+					workClientAttachmentDao.update(workClientAttachment);
+				}
+			} else {
+				workClientAttachmentDao.delete(workClientAttachment);
+			}
+		}
+	}
+
+	/**
+	 * 提交存储
+	 * @param
+	 * @param variables
+	 */
+	@Transactional(readOnly = false)
+	public String save(WorkStock workStock, Map<String, Object> variables, String processInstanceId) {
+			User user = UserUtils.getUser();
+			if(StringUtils.isBlank(workStock.getNumber())){
+				workStock.setNumber(serialNumTplService.genSerialNum(user.getCompany(), workStock.SERIAL_BIZCODE));
+			}
+			super.save(workStock);
+			String str = "采购编号:"+workStock.getNumber()+",采购日期:"+ DateUtils.formatDate(workStock.getCreateDate());
+			String title = "采购申请人:"+user.getName()+",所属部门:"+workStock.getOfficeName();
+			updateWorkReimbursementInfo(workStock);
+			// 用来设置启动流程的人员ID,引擎会自动把用户ID保存到activiti:initiator中
+			identityService.setAuthenticatedUserId(user.getId());
+			// 启动流程
+			String businessKey = workStock.getId().toString();
+			Office office = UserUtils.getSelectOffice();
+			WorkActivityMenu workActivityMenu = workActivityMenuService.findByParentAndOffice("ggh3125f1f194c82bdeocggldc750904", office);
+			// 启动流程
+			String processType = workActivityMenu.getProcessType();
+			StringBuffer buffer = new StringBuffer();
+			Activity activity = new Activity();
+			WorkProjectNotify workProjectNotify = UtilNotify
+					.saveNotify(workStock.getId(),
+							null,
+							workStock.getCompanyId(),
+							title,
+							str,
+							"61",
+							"0",
+							"待审批",
+							""
+					);
+			List<User> users = new ArrayList<>();
+			List<User> zjls = UserUtils.getByRoleActivityEnname("zjl",3,office.getId(),"14",workStock.getCreateBy());
+			List<User> xzzgs = UserUtils.getByRoleActivityEnname("xzzg",3,office.getId(),"14",workStock.getCreateBy());
+
+			if (StringUtils.isNotBlank(workActivityMenu.getId())) {
+				workProjectNotify.setNotifyRole("");
+				workActivityMenu = workActivityMenuService.get(workActivityMenu.getId());
+				List<Activity> activities = workActivityMenu.getActivities();
+				for (Activity a : activities) {
+					String encount = a.getEncount();
+					String enlist = a.getEnlist();
+					if (a.getRole()!=null && StringUtils.isNotBlank(a.getRole().getEnname())){
+						List enusers = UserUtils.getByRoleActivityEnnames(a.getRole().getEnname(),office.getId(),"14",workStock.getCreateBy());
+						if (enusers.size()==0){
+							workStock.setStatus("1");
+							this.save(workStock);
+							return "流程审批人不能为空,角色"+a.getRole().getName()+"下无用户,请联系管理员!";
+						}
+						variables.put(enlist, enusers);
+						variables.put(encount, enusers.size());
+					}
+					if (a.getDelFlag().equals("0") && a.getCount() == 1) {
+						activity = a;
+					}
+				}
+				buffer.append(activity.getRole().getEnname());
+				if (activity != null && StringUtils.isNotBlank(activity.getId())) {
+					//角色审批
+					if (StringUtils.isNotBlank(activity.getRole().getEnname())) {
+						users = UserUtils.getByRoleActivityEnnames(activity.getRole().getEnname(),office.getId(),"14",workStock.getCreateBy());
+					}
+					//人员审批
+					if (StringUtils.isNotBlank(activity.getUser().getId())) {
+						users.add(activity.getUser());
+					}
+				}
+				workProjectNotify.setId("");
+			} else {
+				variables.put("zjlList", zjls);
+				//variables.put("xzzgList", xzzgs);
+				//variables.put("xzzgsList", xzzgs);
+				if (zjls.size()==0 || xzzgs.size()==0){
+					workStock.setStatus("1");
+					this.save(workStock);
+				}
+				if (zjls.size()==0){
+					return "流程审批人不能为空,角色总经理下无用户,请联系管理员!";
+				}
+				/*if (xzzgs.size()==0){
+					return "流程审批人不能为空,角色行政主管下无用户,请联系管理员!";
+				}*/
+				variables.put("zjlcount",zjls.size());
+				variables.put("xzzgcount",xzzgs.size());
+				variables.put("xzzgscount",xzzgs.size());
+				processType = "workstock";
+				users.addAll(zjls);
+			}
+			for (User u : users){
+				workProjectNotify.setUser(u);
+				workProjectNotify.setId("");
+				workProjectNotify.setNotifyRole("总经理审批");
+				workProjectNotifyService
+						.save(workProjectNotify);
+				Map<String,Object> extras = new HashMap<>();
+				extras.put("type","7001");
+				extras.put("id",workProjectNotify.getId());
+				extras.put("procDefKey","61");
+				UserUtils.pushInfoToApp(title,str,extras,u.getId());
+				UserUtils.pushIm(u.getId(),str);
+			}
+			variables.put("type", processType);
+			variables.put("busId", businessKey);
+			variables.put("title", "审批单:" + workStock.getNumber());//设置标题;
+
+			ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(processType, businessKey, variables);
+			workStock.setProcessInstance(processInstance);
+			if (StringUtils.isNotBlank(processInstanceId)) {
+				workActivityProcessService.updateProcessInstanceId(processInstance.getId(),processInstanceId);
+				workActivityProcessService.deleteProcessInstanceId(processInstanceId);
+				workActivityProcessService.deleteProcessIdAuditUsers(processInstanceId);
+			}
+			// 更新流程实例ID
+			workStock.setProcessInstanceId(processInstance.getId());
+			workStockDao.updateProcessInstanceId(workStock);
+			List<Activity> list = workActivityMenu.getActivities();
+			if (list != null && list.size() != 0) {
+				workActivityProcessService.saveList(list, processInstance.getId());
+			} else {
+				WorkActivityProcess workActivityProcess = new WorkActivityProcess();
+				workActivityProcess.setProcessKey("workstock");
+				workActivityProcess.setCount(1);
+				workActivityProcess.setProcessInstanceId(processInstance.getId());
+				workActivityProcess.setIsApproval("0");
+				workActivityProcessService.save(workActivityProcess);
+				workActivityProcess.setCount(2);
+				workActivityProcess.setId("");
+				workActivityProcessService.save(workActivityProcess);
+				workActivityProcess.setCount(3);
+				workActivityProcess.setId("");
+				workActivityProcessService.save(workActivityProcess);
+				workActivityProcessService.insertAuditsByType(zjls,processInstance.getId(),1,1);
+				workActivityProcessService.insertAuditsByType(xzzgs,processInstance.getId(),2,0);
+				workActivityProcessService.insertAuditsByType(xzzgs,processInstance.getId(),3,0);
+			}
+			logger.debug("start process of {key={}, bkey={}, pid={}, variables={}}", new Object[]{
+					ActUtils.PD_REIMBURSEMENT[0], businessKey, processInstance.getId(), variables});
+		return "";
+	}
+	@Transactional(readOnly = false)
+	public void delete(WorkStock workStock) {
+		super.delete(workStock);
+		for (WorkCatalogueItemStock workAccount : workStock.getWorkCatalogueItemStocks()){
+			workCatalogueItemStockDao.delete(workAccount);
+		} for (WorkItemStock workAccount : workStock.getWorkItemStocks()){
+			workItemStockDao.delete(workAccount);
+		}
+		WorkProjectNotify notify = new WorkProjectNotify();
+		notify.setNotifyId(workStock.getId());
+		workProjectNotifyService.readByNotifyId(notify);
+	}
+
+	/**
+	 * 审核流程
+	 * @param
+	 */
+	@Transactional(readOnly = false)
+	public String auditSave(WorkStock workStock,List<User> auditUsers) {
+			String userName = UserUtils.get(workStock.getCreateBy().getId()).getName();
+			String str = "采购编号:"+workStock.getNumber()+",采购日期:"+ DateUtils.formatDate(workStock.getCreateDate());
+			String title = "采购申请人:"+userName+",所属部门:"+workStock.getOfficeName();
+			// 对不同环节的业务逻辑进行操作
+			String taskDefKey = workStock.getAct().getTaskDefKey();
+			if ("zjl".equals(taskDefKey)) {
+				actTaskService.claim(workStock.getAct().getTaskId(), UserUtils.getUser().getId());
+			}else if("xzzg".equals(taskDefKey) || "xzzgs".equals(taskDefKey)){
+				workStock.getAct().setFlag("yes");
+				updateWorkReimbursementInfo(workStock);
+			} else {
+				workStock.getAct().setFlag("yes");
+				updateWorkReimbursementInfo(workStock);
+			}
+			String comment = "";
+			if (workStock.getStatus().equals("4")){
+				comment = ("yes".equals(workStock.getAct().getFlag())?"[重新申请] ":"[已撤销] ");
+			}else {
+				comment = ("yes".equals(workStock.getAct().getFlag())?"[同意] ":"[驳回] ")+workStock.getAct().getComment();
+			}
+			//yes 的时候状态为审核通过 否则为未通过
+			workStock.setStatus(("yes".equals(workStock.getAct().getFlag()) ? "2" : "4"));
+			//String buffer = UserUtils.getRoleActivityEnname(UserUtils.getSelectCompany().getId(),workStock.getCreateBy());
+			Map<String, Object> vars = Maps.newHashMap();
+			//业务逻辑对应的条件表达式
+			String exp = "";
+			String taskCount = "";
+			String notifyRole = "";
+			int sign = 0;
+			int key = 0;
+			String enname = "";
+			List<Activity> activitieList = activityService.getByProcessInstanceId(workStock.getProcessInstanceId());
+			WorkActivityMenu workActivityMenu = new WorkActivityMenu();
+			if (activitieList != null && activitieList.size() != 0) {
+				workActivityMenu.setProcessType(activitieList.get(0).getProcessKey());
+				workActivityMenu.setActivities(activitieList);
+			}
+
+			WorkActivityProcess workActivityProcess = new WorkActivityProcess();
+			WorkActivityProcess selectProcess = new WorkActivityProcess();
+			selectProcess.setProcessInstanceId(workStock.getProcessInstanceId());
+			List<WorkActivityProcess> workActivityProcesses = workActivityProcessService.findList(selectProcess);
+			List<Activity> activities = workActivityMenu.getActivities();
+			if (StringUtils.isNotBlank(workActivityMenu.getProcessType()) && !workActivityMenu.getProcessType().equals("workstock")) {
+				key = 1;
+				for (int i = 0; i < workActivityProcesses.size(); i++) {
+					WorkActivityProcess activityProcess = workActivityProcesses.get(i);
+					if (taskDefKey.equals(activityProcess.getActivityTask()) && !taskDefKey.equals("modifyApply")) {
+						taskCount = activityProcess.getCount()+"";
+						workActivityProcess = activityProcess;
+						if (!workActivityProcess.getIsApproval().equals("0")) {
+							workActivityProcess.setId("");
+						}
+						exp = "pass";
+						if (!"yes".equals(workStock.getAct().getFlag())) {
+							workStock.setStatus("4");
+							workActivityProcess.setIsApproval("2");
+							String returnBack = "-1";
+							for (Activity activity : activities) {
+								if (activity.getCount() == activityProcess.getCount()) {
+									notifyRole = activity.getName();
+									returnBack = activity.getReturnBack();
+									break;
+								}
+							}
+							if (returnBack.equals("0")) {
+								workActivityProcess.setId("");
+							}
+
+						} else {
+							workActivityProcess.setIsApproval("1");
+						}
+					}else if(taskDefKey.equals("modifyApply")){
+						notifyRole = "调整申请";
+						taskCount = "0";
+						exp = "pass";
+						workActivityProcess.setId("");
+						workActivityProcess.setCount(0);
+						if (!"yes".equals(workStock.getAct().getFlag())) {
+							workStock.setStatus("3");
+							workActivityProcess.setIsApproval("2");
+						} else {
+							workActivityProcess.setIsApproval("1");
+						}
+						break;
+					}
+				}
+			} else {
+				workActivityMenu.setProcessType("workstock");
+				for (int i = 0; i < workActivityProcesses.size(); i++) {
+					WorkActivityProcess activityProcess = workActivityProcesses.get(i);
+					String count = activityProcess.getCount() + "";
+					workActivityProcess = activityProcess;
+					if (!workActivityProcess.getIsApproval().equals("0")) {
+						workActivityProcess.setId("");
+					}
+					// 审核环节
+					if ("zjl".equals(taskDefKey) && count.contains("1")) {
+						taskCount = "1";
+						exp = "pass";
+						if ("yes".equals(workStock.getAct().getFlag())) {
+							vars.put("xzzgList", auditUsers);
+							vars.put("xzzgcount",auditUsers.size());
+							workActivityProcessService.insertAuditsByType(auditUsers,workStock.getProcessInstanceId(),2,1);
+							notifyRole = "行政主管";
+							workActivityProcess.setIsApproval("1");
+							enname = "xzzg";
+						} else {
+							notifyRole = "调整申请";
+							workActivityProcess.setIsApproval("2");
+						}
+						break;
+					} else if ("xzzg".equals(taskDefKey) && count.contains("2")) {
+						taskCount = "2";
+						exp = "pass";
+						int type = 0;
+						List<WorkItemStock> list = workStock.getWorkItemStocks();
+						if(list!=null && list.size()>0){
+							for (WorkItemStock w:
+								 list) {
+								//是固定资产
+								if("1".equals(w.getIsAssets())){
+                                    type +=1;
+                                    int _count = Integer.parseInt(w.getCount());//固定资产数量
+									for(int a=0; a<_count ;a++){
+										WorkItemStock workItemStock = new WorkItemStock();
+										try {
+											MyBeanUtils.copyBean2Bean(workItemStock,w);
+											workItemStock.setId(IdGen.uuid());
+										} catch (Exception e) {
+											e.printStackTrace();
+										}
+										workItemStock.setAssetsNumber(serialNumTplService.genSerialNum(UserUtils.getUser().getCompany(), w.SERIAL_BIZCODE));
+										workItemStock.preInsert();
+										workItemStock.setSign("1");
+										workItemStock.setCount("1");
+										workItemStockDao.insert(workItemStock);
+									}
+								}
+							}
+						}
+						//根据是否固定资产做判断  是-行政主管验收编码
+						if (type>0) {
+							vars.put("xzzgsList", auditUsers);
+							vars.put("xzzgscount",auditUsers.size());
+							workActivityProcessService.insertAuditsByType(auditUsers,workStock.getProcessInstanceId(),3,1);
+							notifyRole = "行政主管";
+							workActivityProcess.setIsApproval("1");
+							enname = "xzzg";
+						} else {
+							//否-流程结束
+							workStock.getAct().setFlag("no");
+							sign +=1;
+							notifyRole = "审批通过";
+							workActivityProcess.setIsApproval("1");
+						}
+						break;
+					} else if ("xzzgs".equals(taskDefKey) && count.contains("3")) {
+						taskCount = "3";
+						exp = "pass";
+						if ("yes".equals(workStock.getAct().getFlag())) {
+							notifyRole = "审批通过";
+							workActivityProcess.setIsApproval("1");
+						} else {
+							notifyRole = "调整申请";
+							workActivityProcess.setIsApproval("2");
+						}
+						break;
+					}else if ("modifyApply".equals(taskDefKey)&& count.contains("0")) {
+						notifyRole = "总经理审批";
+						taskCount = "0";
+						exp = "pass";
+						workActivityProcess.setCount(0);
+						enname = "zjl";
+						if (!"yes".equals(workStock.getAct().getFlag())) {
+							workStock.setStatus("3");
+						}
+						break;
+					} else if ("apply_end".equals(taskDefKey)) {
+					}
+
+				}
+			}
+			// 设置意见
+			workStock.getAct().setComment(("yes".equals(workStock.getAct().getFlag()) ? "[同意] " : "[驳回] ") + workStock.getAct().getComment());
+			workStock.preUpdate();
+			// 提交流程任务
+			vars.put(exp, "yes".equals(workStock.getAct().getFlag()) ? true : false);
+			vars.put("passs", true);
+			if(sign >0){
+				workStock.getAct().setFlag("yes");
+				workActivityProcessService.updateProcess(workActivityProcess,workActivityMenu,key,taskCount,workStock.getProcessInstanceId(),taskDefKey,"modifyApply",workStock.getAct().getFlag(),comment, activities);
+				WorkActivityProcess workActivityP = new WorkActivityProcess();
+				workActivityP.setProcessInstanceId(workStock.getProcessInstanceId());
+				List<WorkActivityProcess> processList = workActivityProcessService.findList(workActivityP);
+				if(processList!=null && processList.size()>0){
+					for (int i =0;i<processList.size();i++) {
+						WorkActivityProcess p = processList.get(i);
+						if(3 == p.getCount()){
+							p.setDelFlag("1");
+							p.setIsApproval("-1");
+							workActivityProcessDao.updateDelFlagAndIsApproval(p);
+						}
+					}
+				}
+				workStock.getAct().setFlag("no");
+			}else {
+				workActivityProcessService.updateProcess(workActivityProcess,workActivityMenu,key,taskCount,workStock.getProcessInstanceId(),taskDefKey,"modifyApply",workStock.getAct().getFlag(),comment, activities);
+			}
+			// 提交流程任务
+			actTaskService.complete(workStock.getAct().getTaskId(), workStock.getAct().getProcInsId(), workStock.getAct().getComment(), vars);
+			boolean state = actTaskService.isProcessEnd(workStock.getAct().getProcInsId());
+			List<User> users = new ArrayList<>();
+			List<User> userList = new ArrayList<>();
+			if (!state) {
+				title =  "采购编号"+workStock.getNumber();
+				str = "采购编号:"+workStock.getNumber()+",采购日期:"+ DateUtils.formatDate(workStock.getCreateDate());
+				users.add(workStock.getCreateBy());
+				/*if ("yes".equals(workStock.getAct().getFlag())) {*/
+					workStock.setStatus("5");
+					WorkProjectNotify notify = new WorkProjectNotify();
+					notify.setNotifyId(workStock.getId());
+					userList = workProjectNotifyService.readByNotifyId(notify);
+					users.addAll(userList);
+					workProjectNotifyService
+							.save(UtilNotify
+									.saveNotify(workStock.getId(),
+											workStock.getCreateBy(),
+											workStock.getCompanyId(),
+											title,
+											str,
+											"61",
+											"0",
+											"待通知",
+											notifyRole));
+
+				/*} else {
+					WorkProjectNotify notify = new WorkProjectNotify();
+					notify.setNotifyId(workStock.getId());
+					List<User> userList = workProjectNotifyService.readByNotifyId(notify);
+					users.addAll(userList);
+					if (StringUtils.isNotBlank(workStock.getStatus()) && !workStock.getStatus().equals("3")){
+						title = "您的物品采购申请:"+workStock.getNumber()+":被驳回!";
+						workStock.setStatus("4");
+						workProjectNotifyService
+								.save(UtilNotify
+										.saveNotify(workStock.getId(),
+												workStock.getCreateBy(),
+												workStock.getCompanyId(),
+												title,
+												str,
+												"61",
+												"0",
+												"待通知",
+												notifyRole));
+					}
+				}*/
+				workActivityProcessService.deleteProcessIdAuditUsers(workStock.getProcessInstanceId());
+			} else {
+				if (StringUtils.isNotBlank(workActivityMenu.getProcessType()) && !workActivityMenu.getProcessType().equals("workstock")) {
+					WorkProjectNotify notify = new WorkProjectNotify();
+					notify.setNotifyId(workStock.getId());
+					userList = workProjectNotifyService.readByNotifyId(notify);
+					WorkProjectNotify workProjectNotify = UtilNotify
+							.saveNotify(workStock.getId(),
+									new User(),
+									workStock.getCompanyId(),
+									title,
+									str,
+									"61",
+									"0",
+									"待审批",
+									notifyRole);
+					List<WorkProjectNotify> workProjectNotifys = activityService.getByFlagAndTaskDefKeyList(
+							activities,
+							workProjectNotify,
+							taskDefKey,
+							workStock.getAct().getFlag(),
+							taskCount,
+							workStock.getCreateBy(),
+							workStock.getOfficeId(),
+							"14");
+					for (WorkProjectNotify workProjectNotify1:workProjectNotifys){
+						users.add(workProjectNotify1.getUser());
+						workProjectNotify1.setId("");
+						workProjectNotify1.setIsNewRecord(false);
+						workProjectNotifyService
+								.save(workProjectNotify1);
+						if (!"modifyApply".equals(taskDefKey)){
+							Map<String,Object> extras = new HashMap<>();
+								extras.put("type","7001");
+							extras.put("id",workProjectNotify.getId());
+							extras.put("procDefKey","61");
+							UserUtils.pushInfoToApp(title,str,extras,workProjectNotify1.getUser().getId());
+
+						}
+					}
+					workActivityProcessService.deleteProcessIdAuditUsers(workStock.getProcessInstanceId());
+				} else {
+					if (!"yes".equals(workStock.getAct().getFlag())) {
+						WorkProjectNotify notify = new WorkProjectNotify();
+						notify.setNotifyId(workStock.getId());
+						userList = workProjectNotifyService.readByNotifyId(notify);
+						workProjectNotifyService
+								.save(UtilNotify
+										.saveNotify(workStock.getId(),
+												workStock.getCreateBy(),
+												workStock.getCompanyId(),
+												title,
+												str,
+												"61",
+												"0",
+												"重新申请",
+												notifyRole));
+						users.add( workStock.getCreateBy());
+					} else {
+						if (StringUtils.isNotBlank(enname)) {
+							WorkProjectNotify notify = new WorkProjectNotify();
+							notify.setNotifyId(workStock.getId());
+							userList = workProjectNotifyService.readByNotifyId(notify);
+							WorkProjectNotify workProjectNotify = UtilNotify
+									.saveNotify(workStock.getId(),
+											new User(),
+											workStock.getCompanyId(),
+											title,
+											str,
+											"61",
+											"0",
+											"待审批",
+											notifyRole);
+							users.addAll(auditUsers);
+							for (User user1:auditUsers) {
+								users.add(user1);
+								workProjectNotify.setUser(user1);
+								workProjectNotify.setId("");
+								workProjectNotify.setIsNewRecord(false);
+								workProjectNotifyService
+										.save(workProjectNotify);
+								if (!"modifyApply".equals(taskDefKey)) {
+									Map<String, Object> extras = new HashMap<>();
+									extras.put("type", "7001");
+									extras.put("id", workProjectNotify.getId());
+									extras.put("procDefKey", "61");
+									UserUtils.pushInfoToApp(title, str, extras, user1.getId());
+
+								}
+							}
+						}else {
+							WorkProjectNotify notify = new WorkProjectNotify();
+							notify.setNotifyId(workStock.getId());
+							userList = workProjectNotifyService.readByNotifyId(notify);
+							users.addAll(userList);
+							users.add(workStock.getCreateBy());
+							workProjectNotifyService
+									.save(UtilNotify
+											.saveNotify(workStock.getId(),
+													workStock.getCreateBy(),
+													workStock.getCompanyId(),
+													title,
+													str,
+													"61",
+													"0",
+													"重新申请",
+													notifyRole));
+						}
+					}
+				}
+			}
+		if (StringUtils.isNotBlank(title) && users!=null && users.size()!=0) {
+			for (User u : users) {
+				UserUtils.pushIm(u.getId(),title);
+			}
+		}
+		if (StringUtils.isNotBlank(title) && userList!=null && userList.size()!=0) {
+			for (User u : userList) {
+				UserUtils.pushMeIm(u.getId());
+			}
+		}
+			workStockDao.update(workStock);
+			if("5".equals(workStock.getStatus())){
+				List<WorkItemStock> list = workStock.getWorkItemStocks();
+				if(list!=null && list.size()>0){
+					for (WorkItemStock w:
+						 list) {
+						//非固定资产更改数量
+						if("0".equals(w.getIsAssets())){
+							if(StringUtils.isNotBlank(w.getCatalogueItemId())){
+								WorkItem workItem=workItemDao.getFindItem(w.getCatalogueItemId());
+								//存在做数量增操作
+								if(workItem!=null){
+									int itemcount=workItem.getItemCount();//库存数量
+									if(StringUtils.isNotBlank(w.getCount())){
+										int count = Integer.parseInt(w.getCount());
+										workItem.setItemCount(itemcount+count);
+										workItemDao.update(workItem);
+									}
+								}else{
+									//添加新值
+									WorkItem wItem = new WorkItem();
+									wItem.setIsAssets("0");
+									wItem.setCompanyId(UserUtils.getSelectCompany().getId());
+									wItem.setOfficeId(UserUtils.getSelectOffice().getId());
+									wItem.setCatalogueItemId(w.getCatalogueItemId());
+									wItem.setState("1");//正常
+									if(StringUtils.isNotBlank(w.getCount())){
+										wItem.setItemCount(Integer.parseInt(w.getCount()));
+									}
+									wItem.setId("");
+									wItem.preInsert();
+									wItem.setDelFlag("0");
+									workItemDao.insert(wItem);
+								}
+							}
+						}
+					}
+				}
+				List<WorkItemStock> list2 = workStock.getWorkItemStockAssets();
+				if(list2!=null && list2.size()>0){
+					for (WorkItemStock w:
+							list2) {
+						//固定资产添加新值
+						WorkItem workItem = new WorkItem();
+						workItem.setIsAssets("1");
+						workItem.setCompanyId(UserUtils.getSelectCompany().getId());
+						workItem.setOfficeId(UserUtils.getSelectOffice().getId());
+						workItem.setCatalogueItemId(w.getCatalogueItemId());
+						workItem.setState("1");//正常
+						if(StringUtils.isNotBlank(w.getCount())){
+							workItem.setItemCount(Integer.parseInt(w.getCount()));
+						}
+						workItem.setNumber(w.getAssetsNumber());
+						workItem.setId("");
+						workItem.preInsert();
+						workItem.setDelFlag("0");
+						workItemDao.insert(workItem);
+					}
+				}
+			}
+			return "保存审核意见成功!";
+	}
+
+	/**
+	 * 获取流程详细信息
+	 * @param processInstanceId
+	 */
+	@SuppressWarnings("unchecked")
+	public WorkStock getByProcessInstanceId(String processInstanceId) {
+		WorkStock workStock = workStockDao.getByProcessInstanceId(processInstanceId);
+		return workStock;
+	}
+
+	/**
+	 * 强制撤销
+	 * @param
+	 */
+	@Transactional(readOnly = false)
+	public void cancelInvalidate(WorkStock workStock) {
+		String invalidateProcessInstanceId = workStock.getProcessInstanceId();
+		try {
+			//将流程图中尚未走到的task的流程追踪信息逻辑删除,添加一条"撤销"流程追踪信息
+			WorkActivityProcess process = new WorkActivityProcess();
+			process.setProcessInstanceId(workStock.getProcessInstanceId());
+			process.setIsApproval("0");
+			WorkActivityProcess workActivityProcess = new WorkActivityProcess();
+			workActivityProcess.setProcessInstanceId(workStock.getProcessInstanceId());
+			List<WorkActivityProcess> processList = workActivityProcessService.findList(workActivityProcess);
+			WorkProjectNotify notify = new WorkProjectNotify();
+			notify.setNotifyId(workStock.getId());
+			List<User> userList = workProjectNotifyService.readByNotifyId(notify);
+			if (userList!=null && userList.size()!=0) {
+				for (User u : userList) {
+					User user = UserUtils.get(u.getId());
+					/*List<WebSocket> toUserConns = ChatServerPool.getWebSocketByUser(u.getId());
+					for (WebSocket toUserConn : toUserConns) {
+						String message = "{\"to\":\""+u.getId()+"\"," +
+								"\"msg\":\"审批信息 物品采购申请人:"+ user.getName()+",归档编号:"+workStock.getNumber()+" 强制撤销!\"," +
+								"\"useType\":\"sys\"}";
+						ChatServerPool.sendMessageToUser(toUserConn, message);//同时向本人发送消息
+					}*/
+					UserUtils.pushIm(u.getId(),"物品采购申请人:"+ user.getName()+",归档编号:"+workStock.getNumber()+" 强制撤销!");
+				}
+			}
+			if(processList!=null && processList.size()>0){
+				for (int i =0;i<processList.size();i++) {
+					WorkActivityProcess p = processList.get(i);
+					if(StringUtils.isNotBlank(p.getIsApproval()) && "0".equals(p.getIsApproval())){
+						p.setDelFlag("1");
+						p.setIsApproval("-1");
+						workActivityProcessDao.updateDelFlagAndIsApproval(p);
+					}
+				}
+				WorkActivityProcess pro = new WorkActivityProcess();
+				pro.setId("");
+				pro.preInsert();
+				pro.setDelFlag("0");
+				pro.setRemarks("[强制撤销]");
+				pro.setProcessKey(processList.get(0).getProcessKey());
+				pro.setIsApproval("1");
+				pro.setProcessInstanceId(processList.get(0).getProcessInstanceId());
+				pro.setCount(0);
+				workActivityProcessDao.insert(pro);
+			}
+
+			//结束该流程,设为"撤销"状态
+			actTaskService.endProcessInstance(invalidateProcessInstanceId,"物品采购申请-强制撤销");
+			workStock.setStatus("3");
+			workStock.preUpdate();
+			workStockDao.update(workStock);
+
+			workItemStockDao.deleteByStock(workStock.getId());
+		}catch (ActivitiObjectNotFoundException e){
+			System.err.println("撤销申请异常,因为这个流程已不存在!");
+			e.printStackTrace();
+		}
+		catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
+}

+ 489 - 0
src/main/java/com/jeeplus/modules/workstock/web/WorkStockController.java

@@ -0,0 +1,489 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workstock.web;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.validation.ConstraintViolationException;
+
+import com.google.common.base.Strings;
+import com.google.common.collect.Maps;
+import com.jeeplus.common.mapper.JsonMapper;
+import com.jeeplus.modules.act.entity.Act;
+import com.jeeplus.modules.act.service.ActTaskService;
+import com.jeeplus.modules.sys.entity.Office;
+import com.jeeplus.modules.sys.entity.User;
+import com.jeeplus.modules.sys.service.OfficeService;
+import com.jeeplus.modules.sys.utils.DictUtils;
+import com.jeeplus.modules.sys.utils.UserUtils;
+import com.jeeplus.modules.sysmtree.service.SysMtreeService;
+import com.jeeplus.modules.workactivity.service.ActivityService;
+import com.jeeplus.modules.workbidproject.service.WorkBidProjectService;
+import com.jeeplus.modules.workcatalogueitem.entity.WorkCatalogueItem;
+import com.jeeplus.modules.workcatalogueitem.service.WorkCatalogueItemService;
+import com.jeeplus.modules.workstockcontract.entity.WorkStockContract;
+import com.jeeplus.modules.workstockcontract.service.WorkStockContractService;
+import org.activiti.engine.RuntimeService;
+import org.activiti.engine.TaskService;
+import org.activiti.engine.runtime.ProcessInstance;
+import org.activiti.engine.task.Task;
+import org.apache.commons.lang3.StringEscapeUtils;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.servlet.mvc.support.RedirectAttributes;
+
+import com.google.common.collect.Lists;
+import com.jeeplus.common.utils.DateUtils;
+import com.jeeplus.common.utils.MyBeanUtils;
+import com.jeeplus.common.config.Global;
+import com.jeeplus.common.persistence.Page;
+import com.jeeplus.common.web.BaseController;
+import com.jeeplus.common.utils.StringUtils;
+import com.jeeplus.common.utils.excel.ExportExcel;
+import com.jeeplus.common.utils.excel.ImportExcel;
+import com.jeeplus.modules.workstock.entity.WorkStock;
+import com.jeeplus.modules.workstock.service.WorkStockService;
+
+/**
+ * 物品采购Controller
+ * @author lw
+ * @version 2018-07-13
+ */
+@Controller
+@RequestMapping(value = "${adminPath}/workstock/workStock")
+public class WorkStockController extends BaseController {
+
+	@Autowired
+	private WorkStockService workStockService;
+	@Autowired
+	private WorkCatalogueItemService workCatalogueItemService;
+	@Autowired
+	protected RuntimeService runtimeService;
+	@Autowired
+	protected WorkStockContractService workStockContractService;
+
+	@Autowired
+	protected TaskService taskService;
+
+	@Autowired
+	private ActTaskService actTaskService;
+
+	@Autowired
+	private HttpServletRequest request;
+
+	@ModelAttribute
+	public WorkStock get(@RequestParam(required=false) String id) {
+		WorkStock entity = null;
+		if (StringUtils.isNotBlank(id)){
+			entity = workStockService.get(id);
+		}
+		if (entity == null){
+			entity = new WorkStock();
+		}
+		return entity;
+	}
+	
+	/**
+	 * 物品采购列表页面
+	 */
+	@RequiresPermissions("workstock:workStock:list")
+	@RequestMapping(value = {"list", ""})
+	public String list(WorkStock workStock, HttpServletRequest request, HttpServletResponse response, Model model) {
+		Page<WorkStock> page = workStockService.findPage(new Page<WorkStock>(request, response), workStock); 
+		model.addAttribute("page", page);
+		return "modules/workstock/workStockList";
+	}
+
+	/**
+	 * 查看,增加,编辑物品采购表单页面
+	 */
+	//@RequiresPermissions(value={"workstock:workStock:view","workstock:workStock:add","workstock:workStock:edit"},logical=Logical.OR)
+	@RequestMapping(value = "form")
+	public String form(WorkStock workStock, Model model) {
+		String view = "workStockForm";
+		Office office = UserUtils.getSelectOffice();
+		String tabId = request.getParameter("tabId");
+		if("1".equals(tabId)){
+			view = "workStockView";
+		}else if("3".equals(tabId)){
+			ProcessInstance processInstance = actTaskService.getProcIns(workStock.getProcessInstanceId());
+			if (processInstance!=null) {
+				Task taskInfok = actTaskService.getCurrentTaskInfo(processInstance);
+				Act act = new Act();
+				act.setTaskId(taskInfok.getId());
+				act.setTaskName(taskInfok.getName());
+				act.setTaskDefKey(taskInfok.getTaskDefinitionKey());
+				act.setProcDefId(taskInfok.getProcessDefinitionId());
+				act.setProcInsId(taskInfok.getProcessInstanceId());
+				act.setTask(taskInfok);
+				workStock.setAct(act);
+				view = "workStockModify";
+			}
+		}
+		// 环节编号
+		String taskDefKey = workStock.getAct().getTaskDefKey();
+		if (StringUtils.isNotBlank(taskDefKey) && ("zjl".equals(taskDefKey)
+		)){
+			view = "workStockAudit";
+		}
+		else  if (StringUtils.isNotBlank(taskDefKey) && "xzzg".equals(taskDefKey)){
+			if(workStock.getAcceptDate()== null){
+				workStock.setAcceptDate(new Date());
+			}
+			if(StringUtils.isBlank(workStock.getAcceptName())){
+				workStock.setAcceptName(UserUtils.getUser().getName());
+			}
+			view = "workStockAcceptAudit";
+		}else  if (StringUtils.isNotBlank(taskDefKey) && "xzzgs".equals(taskDefKey)){
+			view = "workStocksAudit";
+		}
+		if (StringUtils.isBlank(workStock.getId())){
+			workStock.setCreateBy(UserUtils.getUser());
+			workStock.setCreateDate(new Date());
+			workStock.setOfficeName(UserUtils.getSelectOffice().getTopCompany());
+		}
+
+		model.addAttribute("workStock", workStock);
+		return "modules/workstock/"+view;
+	}
+
+	/**
+	 * 暂存
+	 */
+	@RequestMapping(value = "store")
+	public String store(WorkStock workStock,
+						Model model,
+						RedirectAttributes redirectAttributes) throws Exception{
+		if (!beanValidator(model, workStock)){
+			return form(workStock, model);
+		}
+
+		User user = workStock.getCreateBy();
+		String submitter = "";
+		if(user != null){
+			submitter = user.getId();
+		}
+		String sta = workStock.getStatus();
+		if(!UserUtils.getUser().getId().equals(submitter) && !Strings.isNullOrEmpty(submitter) && sta != null){
+			addMessage(redirectAttributes, "您不是申请人,无法修改");
+			return "redirect:"+Global.getAdminPath()+"/workstock/workStock/?repage";
+		}
+		workStock.setStatus("1"); //暂存状态
+		workStock.setCompanyId(UserUtils.getSelectCompany().getId());
+		workStock.setOfficeId(UserUtils.getSelectOffice().getId());
+		if (StringUtils.isNotBlank(workStock.getProcessInstanceId()) && workStock.getProcessInstanceId().equals("NULL")){
+			workStock.setProcessInstanceId("");
+		}
+		if(!workStock.getIsNewRecord()){//编辑表单保存
+			WorkStock t = workStockService.get(workStock.getId());//从数据库取出记录的值
+			MyBeanUtils.copyBeanNotNull2Bean(workStock, t);//将编辑表单中的非NULL值覆盖数据库记录中的值
+			workStockService.save(t);//保存
+		}else{//新增表单保存
+			workStockService.save(workStock);//保存
+		}
+		addMessage(redirectAttributes, "保存采购申请成功");
+		return "redirect:"+Global.getAdminPath()+"/workstock/workStock/?repage";
+	}
+
+	/**
+	 * 保存
+	 * 启动流程
+	 */
+	@RequestMapping(value = "save")
+	public String save(WorkStock workStock,
+					   Model model,
+					   RedirectAttributes redirectAttributes) throws Exception{
+		if (!beanValidator(model, workStock)){
+			return form(workStock, model);
+		}
+		User user = workStock.getCreateBy();
+		String sta = workStock.getStatus();
+		if(user!=null && !UserUtils.getUser().getId().equals(user.getId()) && StringUtils.isNotBlank(user.getId())){
+			addMessage(redirectAttributes, "您不是申请人,无法修改");
+			return "redirect:"+Global.getAdminPath()+"/workstock/workStock/?repage";
+		}
+		//状态设置为审核中
+		workStock.setStatus("2");
+		String processInstanceId ="";
+		if (user!=null && StringUtils.isNotBlank(user.getId()) && StringUtils.isNotBlank(sta) && "3".equals(sta)){
+			processInstanceId = workStockService.get(workStock.getId()).getProcessInstanceId();
+		}
+		try {
+			Map<String, Object> variables = Maps.newHashMap();
+			workStock.setCompanyId(UserUtils.getSelectCompany().getId());
+			workStock.setOfficeId(UserUtils.getSelectOffice().getId());
+			String str = workStockService.save(workStock, variables,processInstanceId);
+			if (StringUtils.isNotBlank(str)){
+				addMessage(redirectAttributes, "采购申请提交失败:"+str);
+			}else {
+				addMessage(redirectAttributes, "采购申请已经提交");
+			}
+
+		} catch (Exception e) {
+			addMessage(redirectAttributes, "采购申请提交失败!");
+			addMessage(redirectAttributes, "系统内部错误");
+		}
+		return "redirect:" + adminPath +"/workstock/workStock/?repage";
+	}
+
+	/**
+	 * 工单执行(完成任务)
+	 * @param model
+	 * @return
+	 */
+	@RequestMapping(value = "saveAudit")
+	public String saveAudit(WorkStock workStock, Model model,
+							RedirectAttributes redirectAttributes) {
+		try {
+			try{
+				// 对不同环节的业务逻辑进行操作
+				String taskDefKey = workStock.getAct().getTaskDefKey();
+				List<User> users = null;
+				if ("zjl".equals(taskDefKey)){
+					users = UserUtils.getByProssType(workStock.getProcessInstanceId(),2);
+					if (users==null )
+						users = UserUtils.getByRoleActivityEnname("xzzg",3,workStock.getOfficeId(),"14",workStock.getCreateBy());
+				}else  if ("xzzg".equals(taskDefKey)){
+					users = UserUtils.getByProssType(workStock.getProcessInstanceId(),3);
+					if (users==null )
+						users = UserUtils.getByRoleActivityEnname("xzzg",3,workStock.getOfficeId(),"14",workStock.getCreateBy());
+				}else  if ("xzzgs".equals(taskDefKey)){
+					users = UserUtils.getByProssType(workStock.getProcessInstanceId(),3);
+				}else if ("modifyApply".equals(taskDefKey)){
+					users = UserUtils.getByProssType(workStock.getProcessInstanceId(),1);
+				}
+				String flag = workStock.getAct().getFlag();
+				if ("yes".equals(flag) && (users==null || users.size()==0)){
+					addMessage(redirectAttributes, "审批失败,审批人为空,请联系管理员!");
+				}else {
+					String str = workStockService.auditSave(workStock,users);
+					addMessage(redirectAttributes, str);
+				}
+			}catch (Exception e){
+				addMessage(redirectAttributes, "审批失败");
+			}
+			
+		}catch (Exception e){
+			addMessage(redirectAttributes, "审批失败");
+		}
+		if (StringUtils.isNotBlank(workStock.getHome()) && "home".equals(workStock.getHome())) {
+			return "redirect:" + Global.getAdminPath() + "/home/?repage";
+		} else {
+			return "redirect:" + Global.getAdminPath() + "/workstock/workStock/?repage";
+		}
+	}
+	/**
+	 * 删除物品采购
+	 */
+	@RequiresPermissions("workstock:workStock:del")
+	@RequestMapping(value = "delete")
+	public String delete(WorkStock workStock, RedirectAttributes redirectAttributes) {
+		workStockService.delete(workStock);
+		addMessage(redirectAttributes, "删除物品采购成功");
+		return "redirect:"+Global.getAdminPath()+"/workstock/workStock/?repage";
+	}
+	
+	/**
+	 * 批量删除物品采购
+	 */
+	@RequiresPermissions("workstock:workStock:del")
+	@RequestMapping(value = "deleteAll")
+	public String deleteAll(String ids, RedirectAttributes redirectAttributes) {
+		String idArray[] =ids.split(",");
+		for(String id : idArray){
+			workStockService.delete(workStockService.get(id));
+		}
+		addMessage(redirectAttributes, "删除物品采购成功");
+		return "redirect:"+Global.getAdminPath()+"/workstock/workStock/?repage";
+	}
+	
+	/**
+	 * 导出excel文件
+	 */
+	@RequiresPermissions("workstock:workStock:export")
+    @RequestMapping(value = "export", method=RequestMethod.POST)
+    public String exportFile(WorkStock workStock, HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) {
+		try {
+            String fileName = "物品采购"+DateUtils.getDate("yyyyMMddHHmmss")+".xlsx";
+            Page<WorkStock> page = workStockService.findPage(new Page<WorkStock>(request, response, -1), workStock);
+    		new ExportExcel("物品采购", WorkStock.class).setDataList(page.getList()).write(response, fileName).dispose();
+    		return null;
+		} catch (Exception e) {
+			addMessage(redirectAttributes, "导出物品采购记录失败!失败信息:"+e.getMessage());
+		}
+		return "redirect:"+Global.getAdminPath()+"/workstock/workStock/?repage";
+    }
+
+	/**
+	 * 导入Excel数据
+
+	 */
+	@RequiresPermissions("workstock:workStock:import")
+    @RequestMapping(value = "import", method=RequestMethod.POST)
+    public String importFile(MultipartFile file, RedirectAttributes redirectAttributes) {
+		try {
+			int successNum = 0;
+			int failureNum = 0;
+			StringBuilder failureMsg = new StringBuilder();
+			ImportExcel ei = new ImportExcel(file, 1, 0);
+			List<WorkStock> list = ei.getDataList(WorkStock.class);
+			for (WorkStock workStock : list){
+				try{
+					workStockService.save(workStock);
+					successNum++;
+				}catch(ConstraintViolationException ex){
+					failureNum++;
+				}catch (Exception ex) {
+					failureNum++;
+				}
+			}
+			if (failureNum>0){
+				failureMsg.insert(0, ",失败 "+failureNum+" 条物品采购记录。");
+			}
+			addMessage(redirectAttributes, "已成功导入 "+successNum+" 条物品采购记录"+failureMsg);
+		} catch (Exception e) {
+			addMessage(redirectAttributes, "导入物品采购失败!失败信息:"+e.getMessage());
+		}
+		return "redirect:"+Global.getAdminPath()+"/workstock/workStock/?repage";
+    }
+	
+	/**
+	 * 下载导入物品采购数据模板
+	 */
+	@RequiresPermissions("workstock:workStock:import")
+    @RequestMapping(value = "import/template")
+    public String importFileTemplate(HttpServletResponse response, RedirectAttributes redirectAttributes) {
+		try {
+            String fileName = "物品采购数据导入模板.xlsx";
+    		List<WorkStock> list = Lists.newArrayList(); 
+    		new ExportExcel("物品采购数据", WorkStock.class, 1).setDataList(list).write(response, fileName).dispose();
+    		return null;
+		} catch (Exception e) {
+			addMessage(redirectAttributes, "导入模板下载失败!失败信息:"+e.getMessage());
+		}
+		return "redirect:"+Global.getAdminPath()+"/workstock/workStock/?repage";
+    }
+
+	/**
+	 * 读取单个实体流程
+	 * @return
+	 */
+	@RequestMapping(value = "getProcessOne")
+	public String getProcessOne(WorkStock workStock,Model model) {
+		model.addAttribute("processInstanceId", workStock.getProcessInstanceId());
+		return "modules/workstock/workTrack";
+	}
+	/**
+	 * 强制撤回
+	 */
+	@RequestMapping("cancelInvalidate")
+	public String cancelInvalidate(WorkStock workStock,RedirectAttributes redirectAttributes){
+		workStockService.cancelInvalidate(workStock);
+		return "redirect:"+Global.getAdminPath()+"/workstock/workStock/?repage";
+	}
+	@RequestMapping(value = "getRow")
+	@ResponseBody
+	public String getPNumberr() {
+		HashMap<Object, Object> map = Maps.newHashMap();
+		String obj = request.getParameter("obj");
+		WorkCatalogueItem workCatalogueItem = workCatalogueItemService.get(obj);
+		if(workCatalogueItem!=null){
+			map.put("name",workCatalogueItem.getName());
+			map.put("number",workCatalogueItem.getNumber());
+			map.put("type",workCatalogueItem.getType());
+			map.put("types", DictUtils.getMainDictLabel(workCatalogueItem.getType(),"item_type",""));
+			map.put("model",workCatalogueItem.getModel());
+			map.put("primaryUnit",workCatalogueItem.getPrimaryUnit());
+			String s = StringEscapeUtils.unescapeHtml4(DictUtils.getMainDictLabel(workCatalogueItem.getPrimaryUnit(),"full_count_unit",""));
+			map.put("primaryUnits",s);
+			map.put("catalogueItemId",workCatalogueItem.getId());
+
+		}
+		//map.put("id",workClientInfo.getId());
+		/*if("1".equals(workClientInfo.getCompanyType())){
+			map.put("companyType","政府部门");
+		}else if("2".equals(workClientInfo.getCompanyType())){
+			map.put("companyType","国企");
+		}else if("3".equals(workClientInfo.getCompanyType())){
+			map.put("companyType","民企");
+		}else if("4".equals(workClientInfo.getCompanyType())){
+			map.put("companyType","外资");
+		}else if("5".equals(workClientInfo.getCompanyType())){
+			map.put("companyType","其他");
+		}*/
+		/*if("1".equals(workClientInfo.getCompanyIndustry())){
+			map.put("companyIndustry","电力");
+		}else if("2".equals(workClientInfo.getCompanyIndustry())){
+			map.put("companyIndustry","房地产");
+		}else if("3".equals(workClientInfo.getCompanyIndustry())){
+			map.put("companyIndustry","化工");
+		}else if("4".equals(workClientInfo.getCompanyIndustry())){
+			map.put("companyIndustry","农业");
+		}else if("5".equals(workClientInfo.getCompanyIndustry())){
+			map.put("companyIndustry","交通");
+		}else if("6".equals(workClientInfo.getCompanyIndustry())){
+			map.put("companyIndustry","水利");
+		}else if("7".equals(workClientInfo.getCompanyIndustry())){
+			map.put("companyIndustry","水运");
+		}else if("8".equals(workClientInfo.getCompanyIndustry())){
+			map.put("companyIndustry","教育");
+		}else if("9".equals(workClientInfo.getCompanyIndustry())){
+			map.put("companyIndustry","卫生");
+		}else if("10".equals(workClientInfo.getCompanyIndustry())){
+			map.put("companyIndustry","服务");
+		}*/
+		return JsonMapper.toJsonString(map);
+	}
+
+	@RequestMapping(value = "getContract")
+	public String getContract(WorkStockContract workStockContract, String url, String fieldLabels, String fieldKeys, String searchLabel, String searchKey, HttpServletRequest request, HttpServletResponse response, Model model) {
+		workStockContract.setCompanyId(UserUtils.getSelectCompany().getId());
+		workStockContract.setStatus("5");
+		workStockContract.setCompleteStatus("1");
+		Page<WorkStockContract> page = workStockContractService.findPage(new Page<WorkStockContract>(request, response),  workStockContract);
+		try {
+			fieldLabels = URLDecoder.decode(fieldLabels, "UTF-8");
+			fieldKeys = URLDecoder.decode(fieldKeys, "UTF-8");
+			searchLabel = URLDecoder.decode(searchLabel, "UTF-8");
+			searchKey = URLDecoder.decode(searchKey, "UTF-8");
+		} catch (UnsupportedEncodingException e) {
+			e.printStackTrace();
+		}
+		model.addAttribute("labelNames", fieldLabels.split("\\|"));
+		model.addAttribute("labelValues", fieldKeys.split("\\|"));
+		model.addAttribute("fieldLabels", fieldLabels);
+		model.addAttribute("fieldKeys", fieldKeys);
+		model.addAttribute("url", url);
+		model.addAttribute("searchLabel", searchLabel);
+		model.addAttribute("searchKey", searchKey);
+		model.addAttribute("obj", workStockContract);
+		model.addAttribute("page", page);
+		//return "modules/sys/gridselect";
+		return "modules/sys/gridselectstockcontract";
+	}
+
+	@RequestMapping(value = "setInfo")
+	@ResponseBody
+	public String setInfo() {
+		HashMap<Object, Object> map = Maps.newHashMap();
+		String obj = request.getParameter("contractId");
+		WorkStockContract workStockContract = workStockContractService.get(obj);
+		if(workStockContract!=null){
+			map.put("supplierName",workStockContract.getSupplierName());
+
+		}
+		return JsonMapper.toJsonString(map);
+	}
+}

+ 35 - 0
src/main/java/com/jeeplus/modules/workstockcontract/dao/WorkStockContractDao.java

@@ -0,0 +1,35 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workstockcontract.dao;
+
+import com.jeeplus.modules.worksupplier.entity.WorkSupplier;
+import java.util.List;
+import com.jeeplus.common.persistence.CrudDao;
+import com.jeeplus.common.persistence.annotation.MyBatisDao;
+import com.jeeplus.modules.workstockcontract.entity.WorkStockContract;
+
+/**
+ * 采购合同DAO接口
+ * @author lw
+ * @version 2018-07-11
+ */
+@MyBatisDao
+public interface WorkStockContractDao extends CrudDao<WorkStockContract> {
+
+	public List<WorkSupplier> findListBysupplier(WorkSupplier supplier);
+	/**
+	 * 更新流程实例ID
+	 * @return
+	 */
+	public int updateProcessInstanceId(WorkStockContract workStockContract);
+
+	/**
+	 * 根据流程实例ID获取
+	 * @param processInstanceId
+	 * @return
+	 */
+	public WorkStockContract getByProcessInstanceId(String processInstanceId);
+
+	public int updateCompleteStatus(WorkStockContract workStockContract);
+}

+ 281 - 0
src/main/java/com/jeeplus/modules/workstockcontract/entity/WorkStockContract.java

@@ -0,0 +1,281 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workstockcontract.entity;
+
+import com.google.common.collect.Lists;
+import com.jeeplus.common.persistence.ActEntity;
+import com.jeeplus.modules.sys.utils.UserUtils;
+import com.jeeplus.modules.workcatalogueitem.entity.WorkCatalogueItem;
+import com.jeeplus.modules.workclientinfo.entity.WorkClientAttachment;
+import com.jeeplus.modules.workitemstock.entity.WorkItemStock;
+import com.jeeplus.modules.worksupplier.entity.WorkSupplier;
+
+import com.jeeplus.common.persistence.DataEntity;
+import com.jeeplus.common.utils.excel.annotation.ExcelField;
+import org.activiti.engine.history.HistoricProcessInstance;
+import org.activiti.engine.repository.ProcessDefinition;
+import org.activiti.engine.runtime.ProcessInstance;
+import org.activiti.engine.task.Task;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 采购合同Entity
+ * @author lw
+ * @version 2018-07-11
+ */
+public class WorkStockContract extends ActEntity<WorkStockContract> {
+	//通知 57
+	private static final long serialVersionUID = 1L;
+	private String processInstanceId;		// 流程号
+	private String officeId;		// 部门
+	private String officeName;      //部门名称
+	private String companyId;		// 公司
+	private String status;		// 状态
+	private String name;		// 合同名称
+	private String number;		// 合同编号
+	private WorkSupplier supplier;		// 供应商
+	private String linkName;		// 联系人名称
+	private String money;		// 合同金额(元)
+	private Date signDate;		// 签订日期
+	private String completeStatus;		// 完成状态 1未完成  2已完成
+	private String home;       //跳转首页标记
+	private List<WorkClientAttachment> workAttachments = Lists.newArrayList();    //附件 103
+	private List<WorkClientAttachment> workRecordAttachments = Lists.newArrayList(); //归档附件 104
+	private Date beginContractDate;		// 开始 签订日期
+	private Date endContractDate;		// 结束 签订日期
+	private List<WorkItemStock> workCatalogueItemList = Lists.newArrayList();//商品列表
+
+	//导出属性
+	private String supplierName;   //供应商名称
+	private String monerStr;       //合同金额
+	// 流程任务
+	private Task task;
+	private Map<String, Object> variables;
+	// 运行中的流程实例
+	private ProcessInstance processInstance;
+	// 历史的流程实例
+	private HistoricProcessInstance historicProcessInstance;
+	// 流程定义
+	private ProcessDefinition processDefinition;
+	public WorkStockContract() {
+		super();
+	}
+
+	public WorkStockContract(String id){
+		super(id);
+	}
+
+	public String getProcessInstanceId() {
+		return processInstanceId;
+	}
+
+	public void setProcessInstanceId(String processInstanceId) {
+		this.processInstanceId = processInstanceId;
+	}
+	
+	public String getOfficeId() {
+		return officeId;
+	}
+
+	public void setOfficeId(String officeId) {
+		this.officeId = officeId;
+	}
+	
+	public String getCompanyId() {
+		return companyId;
+	}
+
+	public void setCompanyId(String companyId) {
+		this.companyId = companyId;
+	}
+	@ExcelField(title="合同状态", align=2, sort=20,dictType = "audit_state")
+	public String getStatus() {
+		return status;
+	}
+
+	public void setStatus(String status) {
+		this.status = status;
+	}
+
+	public Date getBeginContractDate() {
+		return beginContractDate;
+	}
+
+	public void setBeginContractDate(Date beginContractDate) {
+		this.beginContractDate = beginContractDate;
+	}
+
+	public String getOfficeName() {
+		return officeName;
+	}
+
+	public void setOfficeName(String officeName) {
+		this.officeName = officeName;
+	}
+
+	public Date getEndContractDate() {
+		return endContractDate;
+	}
+
+	public void setEndContractDate(Date endContractDate) {
+		this.endContractDate = endContractDate;
+	}
+
+	@ExcelField(title="合同名称", align=2, sort=11)
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+	
+	@ExcelField(title="合同编号", align=2, sort=12)
+	public String getNumber() {
+		return number;
+	}
+	@ExcelField(title="供应商名称", align=2, sort=13)
+	public String getSupplierName() {
+		return supplierName;
+	}
+	@ExcelField(title="合同金额(元)", align=2, sort=15)
+	public String getMonerStr() {
+		return UserUtils.getDecimalFormat(new BigDecimal(this.money));
+	}
+	public void setNumber(String number) {
+		this.number = number;
+	}
+	
+	public WorkSupplier getSupplier() {
+		return supplier;
+	}
+
+	public void setSupplier(WorkSupplier supplier) {
+		this.supplier = supplier;
+	}
+	
+	@ExcelField(title="联系人名称", align=2, sort=14)
+	public String getLinkName() {
+		return linkName;
+	}
+
+	public String getHome() {
+		return home;
+	}
+
+	public void setHome(String home) {
+		this.home = home;
+	}
+
+	public List<WorkClientAttachment> getWorkAttachments() {
+		return workAttachments;
+	}
+
+	public void setWorkAttachments(List<WorkClientAttachment> workAttachments) {
+		this.workAttachments = workAttachments;
+	}
+
+	public List<WorkClientAttachment> getWorkRecordAttachments() {
+		return workRecordAttachments;
+	}
+
+	public void setWorkRecordAttachments(List<WorkClientAttachment> workRecordAttachments) {
+		this.workRecordAttachments = workRecordAttachments;
+	}
+
+	public Task getTask() {
+		return task;
+	}
+
+
+	public void setSupplierName(String supplierName) {
+		this.supplierName = supplierName;
+	}
+
+
+
+	public void setMonerStr(String monerStr) {
+		this.monerStr = monerStr;
+	}
+
+	public void setTask(Task task) {
+		this.task = task;
+	}
+
+	public Map<String, Object> getVariables() {
+		return variables;
+	}
+
+	public void setVariables(Map<String, Object> variables) {
+		this.variables = variables;
+	}
+
+	public ProcessInstance getProcessInstance() {
+		return processInstance;
+	}
+
+	public void setProcessInstance(ProcessInstance processInstance) {
+		this.processInstance = processInstance;
+	}
+
+	public HistoricProcessInstance getHistoricProcessInstance() {
+		return historicProcessInstance;
+	}
+
+	public void setHistoricProcessInstance(HistoricProcessInstance historicProcessInstance) {
+		this.historicProcessInstance = historicProcessInstance;
+	}
+
+	public List<WorkItemStock> getWorkCatalogueItemList() {
+		return workCatalogueItemList;
+	}
+
+	public void setWorkCatalogueItemList(List<WorkItemStock> workCatalogueItemList) {
+		this.workCatalogueItemList = workCatalogueItemList;
+	}
+
+	public ProcessDefinition getProcessDefinition() {
+		return processDefinition;
+	}
+
+	public void setProcessDefinition(ProcessDefinition processDefinition) {
+		this.processDefinition = processDefinition;
+	}
+
+	public void setLinkName(String linkName) {
+		this.linkName = linkName;
+	}
+	
+
+	public String getMoney() {
+		return money;
+	}
+
+	public void setMoney(String money) {
+		this.money = money;
+	}
+	
+	@ExcelField(title="签订日期", align=2, sort=16)
+	public Date getSignDate() {
+		return signDate;
+	}
+
+	public void setSignDate(Date signDate) {
+		this.signDate = signDate;
+	}
+	
+	@ExcelField(title="完成状态", align=2, sort=17,dictType = "complete_status")
+	public String getCompleteStatus() {
+		return completeStatus;
+	}
+
+	public void setCompleteStatus(String completeStatus) {
+		this.completeStatus = completeStatus;
+	}
+	
+}

+ 761 - 0
src/main/java/com/jeeplus/modules/workstockcontract/service/WorkStockContractService.java

@@ -0,0 +1,761 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workstockcontract.service;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.google.common.collect.Maps;
+import com.jeeplus.common.utils.MenuStatusEnum;
+import com.jeeplus.common.utils.StringUtils;
+import com.jeeplus.common.websocket.onchat.ChatServerPool;
+import com.jeeplus.modules.act.service.ActTaskService;
+import com.jeeplus.modules.act.utils.ActUtils;
+import com.jeeplus.modules.isignature.service.ISignatureDocumentService;
+import com.jeeplus.modules.sys.entity.Office;
+import com.jeeplus.modules.sys.entity.User;
+import com.jeeplus.modules.sys.utils.UserUtils;
+import com.jeeplus.modules.workactivity.dao.WorkActivityProcessDao;
+import com.jeeplus.modules.workactivity.entity.Activity;
+import com.jeeplus.modules.workactivity.entity.WorkActivityProcess;
+import com.jeeplus.modules.workactivity.service.ActivityService;
+import com.jeeplus.modules.workactivity.service.WorkActivityProcessService;
+import com.jeeplus.modules.workactivitymenu.entity.WorkActivityMenu;
+import com.jeeplus.modules.workactivitymenu.service.WorkActivityMenuService;
+import com.jeeplus.modules.workclientinfo.dao.WorkClientAttachmentDao;
+import com.jeeplus.modules.workclientinfo.entity.WorkClientAttachment;
+import com.jeeplus.modules.workcontractinfo.service.WorkContractInfoService;
+import com.jeeplus.modules.workcontractrecord.dao.WorkContractRecordDao;
+import com.jeeplus.modules.workitemstock.entity.WorkItemStock;
+import com.jeeplus.modules.workitemstock.service.WorkItemStockService;
+import com.jeeplus.modules.workprojectnotify.entity.WorkProjectNotify;
+import com.jeeplus.modules.workprojectnotify.service.WorkProjectNotifyService;
+import com.jeeplus.modules.workprojectnotify.util.UtilNotify;
+import org.activiti.engine.ActivitiObjectNotFoundException;
+import org.activiti.engine.IdentityService;
+import org.activiti.engine.RuntimeService;
+import org.activiti.engine.runtime.ProcessInstance;
+import org.java_websocket.WebSocket;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.jeeplus.modules.worksupplier.entity.WorkSupplier;
+import com.jeeplus.common.persistence.Page;
+import com.jeeplus.common.service.CrudService;
+import com.jeeplus.modules.workstockcontract.entity.WorkStockContract;
+import com.jeeplus.modules.workstockcontract.dao.WorkStockContractDao;
+
+/**
+ * 采购合同Service
+ * @author lw
+ * @version 2018-07-11
+ */
+@Service
+@Transactional(readOnly = true)
+public class WorkStockContractService extends CrudService<WorkStockContractDao, WorkStockContract> {
+	@Autowired
+	private WorkClientAttachmentDao workClientAttachmentDao;
+	@Autowired
+	private IdentityService identityService;
+	@Autowired
+	private WorkActivityMenuService workActivityMenuService;
+	@Autowired
+	private WorkProjectNotifyService workProjectNotifyService;
+	@Autowired
+	private RuntimeService runtimeService;
+	@Autowired
+	private WorkActivityProcessService workActivityProcessService;
+	@Autowired
+	private ActTaskService actTaskService;
+	@Autowired
+	private ActivityService activityService;
+	@Autowired
+	private WorkActivityProcessDao workActivityProcessDao;
+	@Autowired
+	private WorkStockContractDao workStockContractDao;
+	@Autowired
+	private ISignatureDocumentService signatureDocumentService;
+	@Autowired
+	private WorkItemStockService workItemStockService;
+
+	public WorkStockContract get(String id) {
+		WorkStockContract workStockContract = super.get(id);
+		if(workStockContract!=null){
+			//附件
+			WorkClientAttachment workClientAttachment = new WorkClientAttachment();
+			workClientAttachment.setAttachmentId(id);
+			workClientAttachment.setAttachmentFlag("103");
+			workStockContract.setWorkAttachments(workClientAttachmentDao.findList(workClientAttachment));
+			//归档附件
+			WorkClientAttachment workClientAttachment2 = new WorkClientAttachment();
+			workClientAttachment2.setAttachmentId(id);
+			workClientAttachment2.setAttachmentFlag("104");
+			workStockContract.setWorkRecordAttachments(workClientAttachmentDao.findList(workClientAttachment2));
+			//商品列表
+			if(StringUtils.isNotBlank(id)){
+				WorkItemStock workItemStock = new WorkItemStock();
+				workItemStock.setContractId(id);
+				workStockContract.setWorkCatalogueItemList(workItemStockService.findListByContract(workItemStock));
+			}
+		}
+		return workStockContract;
+	}
+	
+	public List<WorkStockContract> findList(WorkStockContract workStockContract) {
+		return super.findList(workStockContract);
+	}
+	
+	public Page<WorkStockContract> findPage(Page<WorkStockContract> page, WorkStockContract workStockContract) {
+		workStockContract.getSqlMap().put("dsf", dataScopeFilter(workStockContract.getCurrentUser(), "o", "u","s", MenuStatusEnum.WORK_STOCKCONTRACT.getValue()));
+		workStockContract.setPage(page);
+		page.setList(findList(workStockContract));
+		return page;
+	}
+	
+	@Transactional(readOnly = false)
+	public void save(WorkStockContract workStockContract) {
+		super.save(workStockContract);
+		updateWorkReimbursementInfo(workStockContract);
+	}
+	@Transactional(readOnly = false)
+	public void updateWorkReimbursementInfo(WorkStockContract workStockContract) {
+		//附件信息
+		for (WorkClientAttachment workClientAttachment : workStockContract.getWorkAttachments()) {
+			if (workClientAttachment.getId() == null) {
+				continue;
+			}
+			if (WorkClientAttachment.DEL_FLAG_NORMAL.equals(workClientAttachment.getDelFlag())) {
+				if("103".equals(workClientAttachment.getAttachmentFlag())){
+					workClientAttachment.setAttachmentId(workStockContract.getId());
+					workClientAttachment.setAttachmentFlag("103");
+					workClientAttachment.setAttachmentUser(UserUtils.getUser().getId());
+					if (StringUtils.isBlank(workClientAttachment.getId()) || "null".equals(workClientAttachment.getId())) {
+						workClientAttachment.preInsert();
+						workClientAttachmentDao.insert(workClientAttachment);
+						signatureDocumentService.createIsignature(workClientAttachment.getUrl(),workClientAttachment.getAttachmentName(),workClientAttachment.getId(),workStockContract.getName());
+					} else {
+						workClientAttachment.preUpdate();
+						workClientAttachmentDao.update(workClientAttachment);
+					}
+				}else if("104".equals(workClientAttachment.getAttachmentFlag())){
+					workClientAttachment.setAttachmentId(workStockContract.getId());
+					workClientAttachment.setAttachmentFlag("104");
+					workClientAttachment.setAttachmentUser(UserUtils.getUser().getId());
+					if (StringUtils.isBlank(workClientAttachment.getId()) || "null".equals(workClientAttachment.getId())) {
+						workClientAttachment.preInsert();
+						workClientAttachmentDao.insert(workClientAttachment);
+						signatureDocumentService.createIsignature(workClientAttachment.getUrl(),workClientAttachment.getAttachmentName(),workClientAttachment.getId(),workStockContract.getName());
+					} else {
+						workClientAttachment.preUpdate();
+						workClientAttachmentDao.update(workClientAttachment);
+					}
+				}
+			} else {
+				workClientAttachmentDao.delete(workClientAttachment);
+			}
+		}
+	}
+	@Transactional(readOnly = false)
+	public void delete(WorkStockContract workStockContract) {
+		super.delete(workStockContract);
+		WorkProjectNotify notify = new WorkProjectNotify();
+		notify.setNotifyId(workStockContract.getId());
+		workProjectNotifyService.readByNotifyId(notify);
+	}
+	
+	public Page<WorkSupplier> findPageBysupplier(Page<WorkSupplier> page, WorkSupplier supplier) {
+		supplier.setPage(page);
+		page.setList(dao.findListBysupplier(supplier));
+		return page;
+	}
+
+	/**
+	 * 审核流程
+	 * @param
+	 */
+	@Transactional(readOnly = false)
+	public String auditSave(WorkStockContract workStockContract,List<User> auditUsers) {
+			String str = "";
+			if(workStockContract.getSupplier()!=null){
+				str =  "合同编号:"+workStockContract.getNumber()+",供应商名称:"+workStockContract.getSupplier().getName()+",合同金额(元):"+workStockContract.getMoney();
+			}else{
+				str =  "合同编号:"+workStockContract.getNumber()+",合同金额(元):"+workStockContract.getMoney();
+			}
+			String title = "合同名称:"+workStockContract.getName();
+			// 对不同环节的业务逻辑进行操作
+			String taskDefKey = workStockContract.getAct().getTaskDefKey();
+			if (!"modifyApply".equals(taskDefKey) && !"sqr".equals(taskDefKey)) {
+				actTaskService.claim(workStockContract.getAct().getTaskId(), UserUtils.getUser().getId());
+			}else {
+				workStockContract.getAct().setFlag("yes");
+				updateWorkReimbursementInfo(workStockContract);
+			}
+			String comment = "";
+			if (workStockContract.getStatus().equals("4")){
+				comment = ("yes".equals(workStockContract.getAct().getFlag())?"[重新申请] ":"[已撤销] ");
+			}else {
+				comment = ("yes".equals(workStockContract.getAct().getFlag())?"[同意] ":"[驳回] ")+workStockContract.getAct().getComment();
+			}
+			//yes 的时候状态为审核通过 否则为未通过
+			workStockContract.setStatus(("yes".equals(workStockContract.getAct().getFlag()) ? "2" : "4"));
+			//String buffer = UserUtils.getRoleActivityEnname(UserUtils.getSelectCompany().getId(),workStockContract.getCreateBy());
+			Map<String, Object> vars = Maps.newHashMap();
+			//业务逻辑对应的条件表达式
+			String exp = "";
+			String taskCount = "";
+			String notifyRole = "";
+			List<User> users = new ArrayList<>();
+			List<User> userList = new ArrayList<>();
+			int key = 0;
+			String enname = "";
+			List<Activity> activitieList = activityService.getByProcessInstanceId(workStockContract.getProcessInstanceId());
+			WorkActivityMenu workActivityMenu = new WorkActivityMenu();
+			if (activitieList != null && activitieList.size() != 0) {
+				workActivityMenu.setProcessType(activitieList.get(0).getProcessKey());
+				workActivityMenu.setActivities(activitieList);
+			}
+			WorkActivityProcess workActivityProcess = new WorkActivityProcess();
+			WorkActivityProcess selectProcess = new WorkActivityProcess();
+			selectProcess.setProcessInstanceId(workStockContract.getProcessInstanceId());
+			List<WorkActivityProcess> workActivityProcesses = workActivityProcessService.findList(selectProcess);
+			List<Activity> activities = workActivityMenu.getActivities();
+			if (StringUtils.isNotBlank(workActivityMenu.getProcessType()) && !workActivityMenu.getProcessType().equals("workstockcontract")) {
+				key = 1;
+				for (int i = 0; i < workActivityProcesses.size(); i++) {
+					WorkActivityProcess activityProcess = workActivityProcesses.get(i);
+					if (taskDefKey.equals(activityProcess.getActivityTask()) && !taskDefKey.equals("modifyApply")) {
+						taskCount = activityProcess.getCount()+"";
+						workActivityProcess = activityProcess;
+						if (!workActivityProcess.getIsApproval().equals("0")) {
+							workActivityProcess.setId("");
+						}
+						exp = "pass";
+						if (!"yes".equals(workStockContract.getAct().getFlag())) {
+							workStockContract.setStatus("4");
+							workActivityProcess.setIsApproval("2");
+							String returnBack = "-1";
+							for (Activity activity : activities) {
+								if (activity.getCount() == activityProcess.getCount()) {
+									notifyRole = activity.getName();
+									returnBack = activity.getReturnBack();
+									break;
+								}
+							}
+							if (returnBack.equals("0")) {
+								workActivityProcess.setId("");
+							}
+						} else {
+							workActivityProcess.setIsApproval("1");
+						}
+					}else if(taskDefKey.equals("modifyApply")){
+						notifyRole = "调整申请";
+						taskCount = "0";
+						exp = "pass";
+						workActivityProcess.setId("");
+						workActivityProcess.setCount(0);
+						if (!"yes".equals(workStockContract.getAct().getFlag())) {
+							workStockContract.setStatus("3");
+							workActivityProcess.setIsApproval("2");
+						} else {
+							workActivityProcess.setIsApproval("1");
+						}
+						break;
+					}
+				}
+			} else {
+				workActivityMenu.setProcessType("workstockcontract");
+				for (int i = 0; i < workActivityProcesses.size(); i++) {
+					WorkActivityProcess activityProcess = workActivityProcesses.get(i);
+					String count = activityProcess.getCount() + "";
+					workActivityProcess = activityProcess;
+					if (!workActivityProcess.getIsApproval().equals("0")) {
+						workActivityProcess.setId("");
+					}
+					// 审核环节
+					if ("hzbzr".equals(taskDefKey) && count.contains("1")) {
+						taskCount = "1";
+						exp = "pass";
+						if ("yes".equals(workStockContract.getAct().getFlag())) {
+							vars.put("gzrList", auditUsers);
+							vars.put("gzrcount",auditUsers.size());
+							workActivityProcessService.insertAuditsByType(auditUsers,workStockContract.getProcessInstanceId(),2,1);
+							notifyRole = "盖章人盖章";
+							workActivityProcess.setIsApproval("1");
+							enname = "gzr";
+						} else {
+							notifyRole = "调整申请";
+							workActivityProcess.setIsApproval("2");
+						}
+						break;
+					} else if ("gzr".equals(taskDefKey) && count.contains("2")) {
+						taskCount = "2";
+						exp = "pass";
+						if ("yes".equals(workStockContract.getAct().getFlag())) {
+							notifyRole = "申请人归档";
+							workActivityProcess.setIsApproval("1");
+							enname = "不为空";
+							WorkProjectNotify notify = new WorkProjectNotify();
+							notify.setNotifyId(workStockContract.getId());
+							userList = workProjectNotifyService.readByNotifyId(notify);
+							WorkProjectNotify workProjectNotify = UtilNotify
+									.saveNotify(workStockContract.getId(),
+											workStockContract.getCreateBy(),
+											workStockContract.getCompanyId(),
+											title,
+											str,
+											"57",
+											"0",
+											"待审批",
+											notifyRole);
+							workProjectNotify.setId("");
+							workProjectNotify.setIsNewRecord(false);
+							workProjectNotifyService
+									.save(workProjectNotify);
+							users.add(workStockContract.getCreateBy());
+						} else {
+							notifyRole = "调整申请";
+							workActivityProcess.setIsApproval("2");
+						}
+						break;
+					} else if ("sqr".equals(taskDefKey) && count.contains("3")) {
+						taskCount = "3";
+						exp = "pass";
+						if ("yes".equals(workStockContract.getAct().getFlag())) {
+							notifyRole = "审批通过";
+							workActivityProcess.setIsApproval("1");
+						} else {
+							notifyRole = "调整申请";
+							workActivityProcess.setIsApproval("2");
+						}
+						break;
+					}  else if ("modifyApply".equals(taskDefKey)&& count.contains("0")) {
+						notifyRole = "行政部负责人审批";
+						taskCount = "0";
+						exp = "pass";
+						workActivityProcess.setCount(0);
+						enname = "xzbzr";
+						if (!"yes".equals(workStockContract.getAct().getFlag())) {
+							workStockContract.setStatus("3");
+						}
+						break;
+					} else if ("apply_end".equals(taskDefKey)) {
+					}
+
+				}
+			}
+			// 设置意见
+			workStockContract.getAct().setComment(("yes".equals(workStockContract.getAct().getFlag()) ? "[同意] " : "[驳回] ") + workStockContract.getAct().getComment());
+			workStockContract.preUpdate();
+			// 提交流程任务
+			vars.put(exp, "yes".equals(workStockContract.getAct().getFlag()) ? true : false);
+			vars.put("passs", true);
+			workActivityProcessService.updateProcess(workActivityProcess,workActivityMenu,key,taskCount,workStockContract.getProcessInstanceId(),taskDefKey,"modifyApply",workStockContract.getAct().getFlag(),comment, activities);
+			// 提交流程任务
+			actTaskService.complete(workStockContract.getAct().getTaskId(), workStockContract.getAct().getProcInsId(), workStockContract.getAct().getComment(), vars);
+			boolean state = actTaskService.isProcessEnd(workStockContract.getAct().getProcInsId());
+			if (!state) {
+				if(workStockContract.getSupplier()!=null){
+					str =  "合同编号:"+workStockContract.getNumber()+",供应商名称:"+workStockContract.getSupplier().getName()+",合同金额(元):"+workStockContract.getMoney();
+				}else{
+					str =  "合同编号:"+workStockContract.getNumber()+",合同金额(元):"+workStockContract.getMoney();
+				}
+				title = "合同名称:"+workStockContract.getName();
+				users.add(workStockContract.getCreateBy());
+				if ("yes".equals(workStockContract.getAct().getFlag())) {
+					workStockContract.setStatus("5");
+					WorkProjectNotify notify = new WorkProjectNotify();
+					notify.setNotifyId(workStockContract.getId());
+					userList = workProjectNotifyService.readByNotifyId(notify);
+					workProjectNotifyService
+							.save(UtilNotify
+									.saveNotify(workStockContract.getId(),
+											workStockContract.getCreateBy(),
+											workStockContract.getCompanyId(),
+											title,
+											str,
+											"57",
+											"0",
+											"待通知",
+											notifyRole));
+
+				} else {
+					WorkProjectNotify notify = new WorkProjectNotify();
+					notify.setNotifyId(workStockContract.getId());
+					userList = workProjectNotifyService.readByNotifyId(notify);
+					if (StringUtils.isNotBlank(workStockContract.getStatus()) && !workStockContract.getStatus().equals("3")){
+						title = "您的采购合同申请:"+workStockContract.getName()+":被驳回!";
+						workStockContract.setStatus("4");
+						workProjectNotifyService
+								.save(UtilNotify
+										.saveNotify(workStockContract.getId(),
+												workStockContract.getCreateBy(),
+												workStockContract.getCompanyId(),
+												title,
+												str,
+												"57",
+												"0",
+												"待通知",
+												notifyRole));
+					}
+				}
+				workActivityProcessService.deleteProcessIdAuditUsers(workStockContract.getProcessInstanceId());
+			} else {
+				if (StringUtils.isNotBlank(workActivityMenu.getProcessType()) && !workActivityMenu.getProcessType().equals("workstockcontract")) {
+					WorkProjectNotify notify = new WorkProjectNotify();
+					notify.setNotifyId(workStockContract.getId());
+					userList = workProjectNotifyService.readByNotifyId(notify);
+					WorkProjectNotify workProjectNotify = UtilNotify
+							.saveNotify(workStockContract.getId(),
+									new User(),
+									workStockContract.getCompanyId(),
+									title,
+									str,
+									"57",
+									"0",
+									"待审批",
+									notifyRole);
+					List<WorkProjectNotify> workProjectNotifys = activityService.getByFlagAndTaskDefKeyList(
+							activities,
+							workProjectNotify,
+							taskDefKey,
+							workStockContract.getAct().getFlag(),
+							taskCount,
+							workStockContract.getCreateBy(),
+							workStockContract.getOfficeId(),
+							"13");
+					for (WorkProjectNotify workProjectNotify1:workProjectNotifys){
+						users.add(workProjectNotify1.getUser());
+						workProjectNotify1.setId("");
+						workProjectNotify1.setIsNewRecord(false);
+						workProjectNotifyService
+								.save(workProjectNotify1);
+						if (!"modifyApply".equals(taskDefKey)){
+							Map<String,Object> extras = new HashMap<>();
+							extras.put("type","7001");
+							extras.put("id",workProjectNotify.getId());
+							extras.put("procDefKey","57");
+							UserUtils.pushInfoToApp(title,str,extras,workProjectNotify1.getUser().getId());
+
+						}
+					}
+
+				} else {
+					if (!"yes".equals(workStockContract.getAct().getFlag())&&!enname.contains("不为空")) {
+						WorkProjectNotify notify = new WorkProjectNotify();
+						notify.setNotifyId(workStockContract.getId());
+						userList = workProjectNotifyService.readByNotifyId(notify);
+						workProjectNotifyService
+								.save(UtilNotify
+										.saveNotify(workStockContract.getId(),
+												workStockContract.getCreateBy(),
+												workStockContract.getCompanyId(),
+												title,
+												str,
+												"57",
+												"0",
+												"重新申请",
+												notifyRole));
+						users.add( workStockContract.getCreateBy());
+					} else {
+						if (StringUtils.isNotBlank(enname)&&!enname.contains("不为空")) {
+							WorkProjectNotify notify = new WorkProjectNotify();
+							notify.setNotifyId(workStockContract.getId());
+							userList = workProjectNotifyService.readByNotifyId(notify);
+							WorkProjectNotify workProjectNotify = UtilNotify
+									.saveNotify(workStockContract.getId(),
+											new User(),
+											workStockContract.getCompanyId(),
+											title,
+											str,
+											"57",
+											"0",
+											"待审批",
+											notifyRole);
+							users.addAll(auditUsers);
+							for (User user1:auditUsers){
+								users.add(user1);
+								workProjectNotify.setUser(user1);
+								workProjectNotify.setId("");
+								workProjectNotify.setIsNewRecord(false);
+								workProjectNotifyService
+										.save(workProjectNotify);
+								if (!"modifyApply".equals(taskDefKey)){
+									Map<String,Object> extras = new HashMap<>();
+										extras.put("type","7001");
+									extras.put("id",workProjectNotify.getId());
+									extras.put("procDefKey","57");
+									UserUtils.pushInfoToApp(title,str,extras,user1.getId());
+
+								}
+							}
+						}else if(StringUtils.isBlank(enname)) {
+							WorkProjectNotify notify = new WorkProjectNotify();
+							notify.setNotifyId(workStockContract.getId());
+							userList = workProjectNotifyService.readByNotifyId(notify);
+							users.addAll(userList);
+							users.add(workStockContract.getCreateBy());
+							workProjectNotifyService
+									.save(UtilNotify
+											.saveNotify(workStockContract.getId(),
+													workStockContract.getCreateBy(),
+													workStockContract.getCompanyId(),
+													title,
+													str,
+													"57",
+													"0",
+													"重新申请",
+													notifyRole));
+						}
+					}
+				}
+			}
+			if (users!=null && users.size()!=0) {
+				for (User u : users) {
+					UserUtils.pushIm(u.getId(),str);
+				}
+			}
+			if (userList!=null && userList.size()!=0) {
+				for (User u : userList) {
+					UserUtils.pushMeIm(u.getId());
+				}
+			}
+			workStockContractDao.update(workStockContract);
+		return "保存审核意见成功!";
+	}
+	/**
+	 * 获取流程详细信息
+	 * @param processInstanceId
+	 */
+	@SuppressWarnings("unchecked")
+	public WorkStockContract getByProcessInstanceId(String processInstanceId) {
+		WorkStockContract workStockContract = workStockContractDao.getByProcessInstanceId(processInstanceId);
+		return workStockContract;
+	}
+	/**
+	 * 提交存储
+	 * @param
+	 * @param variables
+	 */
+	@Transactional(readOnly = false)
+	public String save(WorkStockContract workStockContract, Map<String, Object> variables, String processInstanceId) {
+		try {
+			User user = UserUtils.getUser();
+			super.save(workStockContract);
+			String str = "";
+			if(workStockContract.getSupplier()!=null){
+				str =  "合同编号:"+workStockContract.getNumber()+",供应商名称:"+workStockContract.getSupplier().getName()+",合同金额(元):"+workStockContract.getMoney();
+			}else{
+				str =  "合同编号:"+workStockContract.getNumber()+",合同金额(元):"+workStockContract.getMoney();
+			}
+			String title = "合同名称:"+workStockContract.getName();
+			updateWorkReimbursementInfo(workStockContract);
+			// 用来设置启动流程的人员ID,引擎会自动把用户ID保存到activiti:initiator中
+			identityService.setAuthenticatedUserId(user.getId());
+			// 启动流程
+			String businessKey = workStockContract.getId().toString();
+			Office office = UserUtils.getSelectOffice();
+			WorkActivityMenu workActivityMenu = workActivityMenuService.findByParentAndOffice("ggh3125f1f194c82bdeoooocdc750904", office);
+			// 启动流程
+			String processType = workActivityMenu.getProcessType();
+			StringBuffer buffer = new StringBuffer();
+			Activity activity = new Activity();
+			WorkProjectNotify workProjectNotify = UtilNotify
+					.saveNotify(workStockContract.getId(),
+							null,
+							workStockContract.getCompanyId(),
+							title,
+							str,
+							"57",
+							"0",
+							"待审批",
+							""
+					);
+			List<User> users = new ArrayList<>();
+			List<User> hzbzrs = UserUtils.getByRoleActivityEnname("xzbzr",3,office.getId(),"13",workStockContract.getCreateBy());
+			List<User> gzrs = UserUtils.getByRoleActivityEnname("gzr",3,office.getId(),"13",workStockContract.getCreateBy());
+			if (StringUtils.isNotBlank(workActivityMenu.getId())) {
+				workProjectNotify.setNotifyRole("");
+				workActivityMenu = workActivityMenuService.get(workActivityMenu.getId());
+				List<Activity> activities = workActivityMenu.getActivities();
+				for (Activity a : activities) {
+					String encount = a.getEncount();
+					String enlist = a.getEnlist();
+					if (a.getRole()!=null && StringUtils.isNotBlank(a.getRole().getEnname())){
+						List enusers = UserUtils.getByRoleActivityEnnames(a.getRole().getEnname(),office.getId(),"13",workStockContract.getCreateBy());
+						if (enusers.size()==0){
+							workStockContract.setStatus("1");
+							this.save(workStockContract);
+							return "流程审批人不能为空,角色"+a.getRole().getName()+"下无用户,请联系管理员!";
+						}
+						variables.put(enlist, enusers);
+						variables.put(encount, enusers.size());
+					}
+					if (a.getDelFlag().equals("0") && a.getCount() == 1) {
+						activity = a;
+					}
+				}
+				buffer.append(activity.getRole().getEnname());
+				if (activity != null && StringUtils.isNotBlank(activity.getId())) {
+					//角色审批
+					if (StringUtils.isNotBlank(activity.getRole().getEnname())) {
+						users = UserUtils.getByRoleActivityEnnames(activity.getRole().getEnname(),office.getId(),"13",workStockContract.getCreateBy());
+					}
+					//人员审批
+					if (StringUtils.isNotBlank(activity.getUser().getId())) {
+						users.add(activity.getUser());
+					}
+				}
+				workProjectNotify.setId("");
+			} else {
+				variables.put("hzbzrList", hzbzrs);
+				//variables.put("gzrList", gzrs);
+				if (hzbzrs.size()==0 || gzrs.size()==0){
+					workStockContract.setStatus("1");
+					this.save(workStockContract);
+				}
+				if (hzbzrs.size()==0){
+					return "流程审批人不能为空,角色行政部负责人下无用户,请联系管理员!";
+				}
+				/*if (gzrs.size()==0){
+					return "流程审批人不能为空,角色盖章人下无用户,请联系管理员!";
+				}*/
+				variables.put("hzbzrcount",hzbzrs.size());
+				//variables.put("gzrcount",gzrs.size());
+				processType = "workstockcontract";
+				users.addAll(hzbzrs);
+			}
+			for (User u : users){
+				workProjectNotify.setUser(u);
+				workProjectNotify.setId("");
+				workProjectNotify.setNotifyRole("行政部负责人审批");
+				workProjectNotifyService
+						.save(workProjectNotify);
+			/*	List<WebSocket> toUserConns = ChatServerPool.getWebSocketByUser(u.getId());
+				for (WebSocket toUserConn:toUserConns) {
+					String message = "{\"to\":\""+u.getId()+"\"," +
+							"\"msg\":\"审批信息 采购合同申请人:"+user.getName()+",采购合同:"+workStockContract.getName() + " 待审批!\"," +
+							"\"useType\":\"sys\"}";*/
+				Map<String,Object> extras = new HashMap<>();
+				extras.put("type","7001");
+				extras.put("id",workProjectNotify.getId());
+				extras.put("procDefKey","57");
+				UserUtils.pushInfoToApp(title,str,extras,u.getId());
+				UserUtils.pushIm(u.getId(),str);
+			}
+			variables.put("type", processType);
+			variables.put("busId", businessKey);
+			variables.put("title", "审批单:" + workStockContract.getName());//设置标题;
+
+			ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(processType, businessKey, variables);
+			workStockContract.setProcessInstance(processInstance);
+			if (StringUtils.isNotBlank(processInstanceId)) {
+				workActivityProcessService.updateProcessInstanceId(processInstance.getId(),processInstanceId);
+				workActivityProcessService.deleteProcessInstanceId(processInstanceId);
+				workActivityProcessService.deleteProcessIdAuditUsers(processInstanceId);
+			}
+			// 更新流程实例ID
+			workStockContract.setProcessInstanceId(processInstance.getId());
+			workStockContractDao.updateProcessInstanceId(workStockContract);
+			List<Activity> list = workActivityMenu.getActivities();
+			if (list != null && list.size() != 0) {
+				workActivityProcessService.saveList(list, processInstance.getId());
+			} else {
+				WorkActivityProcess workActivityProcess = new WorkActivityProcess();
+				workActivityProcess.setProcessKey("workstockcontract");
+				workActivityProcess.setCount(1);
+				workActivityProcess.setProcessInstanceId(processInstance.getId());
+				workActivityProcess.setIsApproval("0");
+				workActivityProcessService.save(workActivityProcess);
+				workActivityProcess.setCount(2);
+				workActivityProcess.setId("");
+				workActivityProcessService.save(workActivityProcess);
+				workActivityProcess.setCount(3);
+				workActivityProcess.setId("");
+				workActivityProcessService.save(workActivityProcess);
+				workActivityProcessService.insertAuditsByType(hzbzrs,processInstance.getId(),1,1);
+				workActivityProcessService.insertAuditsByType(gzrs,processInstance.getId(),2,0);
+			}
+			logger.debug("start process of {key={}, bkey={}, pid={}, variables={}}", new Object[]{
+					ActUtils.PD_REIMBURSEMENT[0], businessKey, processInstance.getId(), variables});
+		}catch (Exception e){
+			logger.info("Exception e:"+e);
+			return "Exception e:"+e;
+		}
+		return "";
+	}
+	/**
+	 * 强制撤销
+	 * @param
+	 */
+	@Transactional(readOnly = false)
+	public void cancelInvalidate(WorkStockContract workStockContract) {
+		String invalidateProcessInstanceId = workStockContract.getProcessInstanceId();
+		try {
+			//将流程图中尚未走到的task的流程追踪信息逻辑删除,添加一条"撤销"流程追踪信息
+			WorkActivityProcess process = new WorkActivityProcess();
+			process.setProcessInstanceId(workStockContract.getProcessInstanceId());
+			process.setIsApproval("0");
+			WorkActivityProcess workActivityProcess = new WorkActivityProcess();
+			workActivityProcess.setProcessInstanceId(workStockContract.getProcessInstanceId());
+			List<WorkActivityProcess> processList = workActivityProcessService.findList(workActivityProcess);
+			WorkProjectNotify notify = new WorkProjectNotify();
+			notify.setNotifyId(workStockContract.getId());
+			List<User> userList = workProjectNotifyService.readByNotifyId(notify);
+			if (userList!=null && userList.size()!=0) {
+				for (User u : userList) {
+					User user = UserUtils.get(u.getId());
+					/*List<WebSocket> toUserConns = ChatServerPool.getWebSocketByUser(u.getId());
+					for (WebSocket toUserConn : toUserConns) {
+						String message = "{\"to\":\""+u.getId()+"\"," +
+								"\"msg\":\"审批信息 采购合同申请人:"+ user.getName()+",采购合同:"+workStockContract.getName()+" 强制撤销!\"," +
+								"\"useType\":\"sys\"}";
+						ChatServerPool.sendMessageToUser(toUserConn, message);//同时向本人发送消息
+					}*/
+					UserUtils.pushIm(u.getId(),"采购合同申请人:"+ user.getName()+",采购合同:"+workStockContract.getName()+" 强制撤销!");
+				}
+			}
+			if(processList!=null && processList.size()>0){
+				for (int i =0;i<processList.size();i++) {
+					WorkActivityProcess p = processList.get(i);
+					if(StringUtils.isNotBlank(p.getIsApproval()) && "0".equals(p.getIsApproval())){
+						p.setDelFlag("1");
+						p.setIsApproval("-1");
+						workActivityProcessDao.updateDelFlagAndIsApproval(p);
+					}
+				}
+				WorkActivityProcess pro = new WorkActivityProcess();
+				pro.setId("");
+				pro.preInsert();
+				pro.setDelFlag("0");
+				pro.setRemarks("[强制撤销]");
+				pro.setProcessKey(processList.get(0).getProcessKey());
+				pro.setIsApproval("1");
+				pro.setProcessInstanceId(processList.get(0).getProcessInstanceId());
+				pro.setCount(0);
+				workActivityProcessDao.insert(pro);
+			}
+
+			//结束该流程,设为"撤销"状态
+			actTaskService.endProcessInstance(invalidateProcessInstanceId,"采购合同申请-强制撤销");
+			workStockContract.setStatus("3");
+			workStockContract.preUpdate();
+			workStockContractDao.update(workStockContract);
+
+		}catch (ActivitiObjectNotFoundException e){
+			System.err.println("撤销合同作废异常,因为这个流程已不存在!");
+			e.printStackTrace();
+		}
+		catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
+
+	@Transactional(readOnly = false)
+	public void updateCompleteStatus(WorkStockContract workStockContract) {
+		workStockContractDao.updateCompleteStatus(workStockContract);
+	}
+}

+ 410 - 0
src/main/java/com/jeeplus/modules/workstockcontract/web/WorkStockContractController.java

@@ -0,0 +1,410 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workstockcontract.web;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.validation.ConstraintViolationException;
+
+import com.google.common.base.Strings;
+import com.google.common.collect.Maps;
+import com.jeeplus.common.mapper.JsonMapper;
+import com.jeeplus.modules.act.entity.Act;
+import com.jeeplus.modules.act.service.ActTaskService;
+import com.jeeplus.modules.sys.entity.Office;
+import com.jeeplus.modules.sys.entity.User;
+import com.jeeplus.modules.sys.utils.UserUtils;
+import com.jeeplus.modules.worksupplier.service.WorkSupplierService;
+import org.activiti.engine.runtime.ProcessInstance;
+import org.activiti.engine.task.Task;
+import org.apache.shiro.authz.annotation.Logical;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.servlet.mvc.support.RedirectAttributes;
+
+import com.jeeplus.modules.worksupplier.entity.WorkSupplier;
+import com.google.common.collect.Lists;
+import com.jeeplus.common.utils.DateUtils;
+import com.jeeplus.common.utils.MyBeanUtils;
+import com.jeeplus.common.config.Global;
+import com.jeeplus.common.persistence.Page;
+import com.jeeplus.common.web.BaseController;
+import com.jeeplus.common.utils.StringUtils;
+import com.jeeplus.common.utils.excel.ExportExcel;
+import com.jeeplus.common.utils.excel.ImportExcel;
+import com.jeeplus.modules.workstockcontract.entity.WorkStockContract;
+import com.jeeplus.modules.workstockcontract.service.WorkStockContractService;
+
+/**
+ * 采购合同Controller
+ * @author lw
+ * @version 2018-07-11
+ */
+@Controller
+@RequestMapping(value = "${adminPath}/workstockcontract/workStockContract")
+public class WorkStockContractController extends BaseController {
+
+	@Autowired
+	private WorkStockContractService workStockContractService;
+	@Autowired
+	private HttpServletRequest request;
+	@Autowired
+	private ActTaskService actTaskService;
+	@Autowired
+	private WorkSupplierService workSupplierService;
+	@ModelAttribute
+	public WorkStockContract get(@RequestParam(required=false) String id) {
+		WorkStockContract entity = null;
+		if (StringUtils.isNotBlank(id)){
+			entity = workStockContractService.get(id);
+		}
+		if (entity == null){
+			entity = new WorkStockContract();
+		}
+		return entity;
+	}
+	
+	/**
+	 * 采购合同列表页面
+	 */
+	@RequiresPermissions("workstockcontract:workStockContract:list")
+	@RequestMapping(value = {"list", ""})
+	public String list(WorkStockContract workStockContract, HttpServletRequest request, HttpServletResponse response, Model model) {
+		Page<WorkStockContract> page = workStockContractService.findPage(new Page<WorkStockContract>(request, response), workStockContract); 
+		model.addAttribute("page", page);
+		return "modules/workstockcontract/workStockContractList";
+	}
+
+	/**
+	 * 查看,增加,编辑采购合同表单页面
+	 */
+	//@RequiresPermissions(value={"workstockcontract:workStockContract:view","workstockcontract:workStockContract:add","workstockcontract:workStockContract:edit"},logical=Logical.OR)
+	@RequestMapping(value = "form")
+	public String form(WorkStockContract workStockContract, Model model) {
+		String view = "workStockContractForm";
+		Office office = UserUtils.getSelectOffice();
+		String tabId = request.getParameter("tabId");
+		if("1".equals(tabId)){
+			view = "workStockContractView";
+		}else if("3".equals(tabId)){
+			ProcessInstance processInstance = actTaskService.getProcIns(workStockContract.getProcessInstanceId());
+			if (processInstance!=null) {
+				Task taskInfok = actTaskService.getCurrentTaskInfo(processInstance);
+				Act act = new Act();
+				act.setTaskId(taskInfok.getId());
+				act.setTaskName(taskInfok.getName());
+				act.setTaskDefKey(taskInfok.getTaskDefinitionKey());
+				act.setProcDefId(taskInfok.getProcessDefinitionId());
+				act.setProcInsId(taskInfok.getProcessInstanceId());
+				act.setTask(taskInfok);
+				workStockContract.setAct(act);
+				view = "workStockContractModify";
+			}
+		}else if("5".equals(tabId)){
+			model.addAttribute("workStockContract", workStockContract);
+			view = "workStockContractForms";
+			return "modules/workstockcontract/"+view;
+		}
+		// 环节编号
+		String taskDefKey = workStockContract.getAct().getTaskDefKey();
+		if (StringUtils.isNotBlank(taskDefKey) && ("hzbzr".equals(taskDefKey))){
+			view = "workStockContractAudit";
+		}else if(StringUtils.isNotBlank(taskDefKey) &&("gzr".equals(taskDefKey))){
+			view = "workStockContractgzAudit";
+		}else if (StringUtils.isNotBlank(taskDefKey) && ("sqr".equals(taskDefKey))){
+			view = "workStockContractSqrAudit";
+		}
+		if(StringUtils.isBlank(workStockContract.getCompleteStatus())){
+			workStockContract.setCompleteStatus("1");//未完成
+			workStockContract.setOfficeName(UserUtils.getSelectOffice().getTopCompany());
+		}
+		model.addAttribute("workStockContract", workStockContract);
+		return "modules/workstockcontract/"+view;
+	}
+	/**
+	 * 暂存
+	 */
+	@RequestMapping(value = "store")
+	public String store(WorkStockContract workStockContract,
+						Model model,
+						RedirectAttributes redirectAttributes) throws Exception{
+		if (!beanValidator(model, workStockContract)){
+			return form(workStockContract, model);
+		}
+		User user = workStockContract.getCreateBy();
+		String submitter = "";
+		if(user != null){
+			submitter = user.getId();
+		}
+		String sta = workStockContract.getStatus();
+		if(!UserUtils.getUser().getId().equals(submitter) && !Strings.isNullOrEmpty(submitter) && sta != null){
+			addMessage(redirectAttributes, "您不是申请人,无法修改");
+			return "redirect:"+Global.getAdminPath()+"/workstockcontract/workStockContract/?repage";
+		}
+		workStockContract.setStatus("1"); //暂存状态
+		workStockContract.setCompanyId(UserUtils.getSelectCompany().getId());
+		workStockContract.setOfficeId(UserUtils.getSelectOffice().getId());
+		if (StringUtils.isNotBlank(workStockContract.getProcessInstanceId()) && workStockContract.getProcessInstanceId().equals("NULL")){
+			workStockContract.setProcessInstanceId("");
+		}
+		if(!workStockContract.getIsNewRecord()){//编辑表单保存
+			WorkStockContract t = workStockContractService.get(workStockContract.getId());//从数据库取出记录的值
+			MyBeanUtils.copyBeanNotNull2Bean(workStockContract, t);//将编辑表单中的非NULL值覆盖数据库记录中的值
+			workStockContractService.save(t);//保存
+		}else{//新增表单保存
+			workStockContractService.save(workStockContract);//保存
+		}
+		addMessage(redirectAttributes, "保存采购合同成功");
+		return "redirect:"+Global.getAdminPath()+"/workstockcontract/workStockContract/?repage";
+	}
+	/**
+	 * 保存采购合同
+	 */
+	@RequiresPermissions(value={"workstockcontract:workStockContract:add","workstockcontract:workStockContract:edit"},logical=Logical.OR)
+	@RequestMapping(value = "save")
+	public String save(WorkStockContract workStockContract, Model model, RedirectAttributes redirectAttributes) throws Exception{
+		if (!beanValidator(model, workStockContract)){
+			return form(workStockContract, model);
+		}
+		User user = workStockContract.getCreateBy();
+		String sta = workStockContract.getStatus();
+		if(user!=null && !UserUtils.getUser().getId().equals(user.getId()) && StringUtils.isNotBlank(user.getId())){
+			addMessage(redirectAttributes, "您不是申请人,无法修改");
+			return "redirect:"+Global.getAdminPath()+"/workstockcontract/workStockContract/?repage";
+		}
+		//状态设置为审核中
+		workStockContract.setStatus("2");
+		String processInstanceId ="";
+		if (user!=null && StringUtils.isNotBlank(user.getId()) && StringUtils.isNotBlank(sta) && "3".equals(sta)){
+			processInstanceId = workStockContractService.get(workStockContract.getId()).getProcessInstanceId();
+		}
+		try {
+			Map<String, Object> variables = Maps.newHashMap();
+			workStockContract.setCompanyId(UserUtils.getSelectCompany().getId());
+			workStockContract.setOfficeId(UserUtils.getSelectOffice().getId());
+			String str = workStockContractService.save(workStockContract, variables,processInstanceId);
+			if (StringUtils.isNotBlank(str)){
+				addMessage(redirectAttributes, "采购合同申请提交失败:"+str);
+			}else {
+				addMessage(redirectAttributes, "采购合同申请已经提交");
+			}
+
+		} catch (Exception e) {
+			addMessage(redirectAttributes, "采购合同申请提交失败!");
+			addMessage(redirectAttributes, "系统内部错误");
+		}
+		return "redirect:"+Global.getAdminPath()+"/workstockcontract/workStockContract/?repage";
+	}
+	/**
+	 * 工单执行(完成任务)
+	 * @param model
+	 * @return
+	 */
+	@RequestMapping(value = "saveAudit")
+	public String saveAudit(WorkStockContract workStockContract, Model model,
+							RedirectAttributes redirectAttributes) {
+		try{
+			// 对不同环节的业务逻辑进行操作
+			String taskDefKey = workStockContract.getAct().getTaskDefKey();
+			List<User> users = null;
+			if ("hzbzr".equals(taskDefKey)) {
+				users = UserUtils.getByProssType(workStockContract.getProcessInstanceId(), 2);
+				if (users==null){
+					users = UserUtils.getByRoleActivityEnname("gzr",3,workStockContract.getOfficeId(),"13",workStockContract.getCreateBy());
+				}
+			}else if("gzr".equals(taskDefKey)) {
+				users = UserUtils.getByProssType(workStockContract.getProcessInstanceId(), 2);
+			}else if("sqr".equals(taskDefKey)) {
+				users = UserUtils.getByProssType(workStockContract.getProcessInstanceId(), 1);
+			}else if("modifyApply".equals(taskDefKey)){
+				users = UserUtils.getByProssType(workStockContract.getProcessInstanceId(), 1);
+			}
+			if ("yes".equals(workStockContract.getAct().getFlag()) && (users==null || users.size()==0)){
+				addMessage(redirectAttributes, "审批失败,审批人为空,请联系管理员!");
+			}else {
+				String str =workStockContractService.auditSave(workStockContract,users);
+				addMessage(redirectAttributes, str);
+			}
+		}catch (Exception e){
+			addMessage(redirectAttributes, "审批失败");
+		}
+		if (StringUtils.isNotBlank(workStockContract.getHome()) && "home".equals(workStockContract.getHome())){
+			return "redirect:" + Global.getAdminPath() + "/home/?repage";
+		}else {
+			return "redirect:"+Global.getAdminPath()+"/workstockcontract/workStockContract/?repage";
+		}
+	}
+	/**
+	 * 读取单个实体流程
+	 * @return
+	 */
+	@RequestMapping(value = "getProcessOne")
+	public String getProcessOne(WorkStockContract workStockContract,Model model) {
+		model.addAttribute("processInstanceId", workStockContract.getProcessInstanceId());
+		return "modules/workstockcontract/workTrack";
+	}
+	/**
+	 * 删除采购合同
+	 */
+	@RequiresPermissions("workstockcontract:workStockContract:del")
+	@RequestMapping(value = "delete")
+	public String delete(WorkStockContract workStockContract, RedirectAttributes redirectAttributes) {
+		workStockContractService.delete(workStockContract);
+		addMessage(redirectAttributes, "删除采购合同成功");
+		return "redirect:"+Global.getAdminPath()+"/workstockcontract/workStockContract/?repage";
+	}
+	
+	/**
+	 * 批量删除采购合同
+	 */
+	@RequiresPermissions("workstockcontract:workStockContract:del")
+	@RequestMapping(value = "deleteAll")
+	public String deleteAll(String ids, RedirectAttributes redirectAttributes) {
+		String idArray[] =ids.split(",");
+		for(String id : idArray){
+			workStockContractService.delete(workStockContractService.get(id));
+		}
+		addMessage(redirectAttributes, "删除采购合同成功");
+		return "redirect:"+Global.getAdminPath()+"/workstockcontract/workStockContract/?repage";
+	}
+	
+	/**
+	 * 导出excel文件
+	 */
+	@RequiresPermissions("workstockcontract:workStockContract:export")
+    @RequestMapping(value = "export", method=RequestMethod.POST)
+    public String exportFile(WorkStockContract workStockContract, HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) {
+		try {
+            String fileName = "采购合同"+DateUtils.getDate("yyyyMMddHHmmss")+".xlsx";
+            Page<WorkStockContract> page = workStockContractService.findPage(new Page<WorkStockContract>(request, response, -1), workStockContract);
+    		new ExportExcel("采购合同", WorkStockContract.class).setDataList(page.getList()).write(response, fileName).dispose();
+    		return null;
+		} catch (Exception e) {
+			addMessage(redirectAttributes, "导出采购合同记录失败!失败信息:"+e.getMessage());
+		}
+		return "redirect:"+Global.getAdminPath()+"/workstockcontract/workStockContract/?repage";
+    }
+
+	/**
+	 * 导入Excel数据
+
+	 */
+	@RequiresPermissions("workstockcontract:workStockContract:import")
+    @RequestMapping(value = "import", method=RequestMethod.POST)
+    public String importFile(MultipartFile file, RedirectAttributes redirectAttributes) {
+		try {
+			int successNum = 0;
+			int failureNum = 0;
+			StringBuilder failureMsg = new StringBuilder();
+			ImportExcel ei = new ImportExcel(file, 1, 0);
+			List<WorkStockContract> list = ei.getDataList(WorkStockContract.class);
+			for (WorkStockContract workStockContract : list){
+				try{
+					workStockContractService.save(workStockContract);
+					successNum++;
+				}catch(ConstraintViolationException ex){
+					failureNum++;
+				}catch (Exception ex) {
+					failureNum++;
+				}
+			}
+			if (failureNum>0){
+				failureMsg.insert(0, ",失败 "+failureNum+" 条采购合同记录。");
+			}
+			addMessage(redirectAttributes, "已成功导入 "+successNum+" 条采购合同记录"+failureMsg);
+		} catch (Exception e) {
+			addMessage(redirectAttributes, "导入采购合同失败!失败信息:"+e.getMessage());
+		}
+		return "redirect:"+Global.getAdminPath()+"/workstockcontract/workStockContract/?repage";
+    }
+	
+	/**
+	 * 下载导入采购合同数据模板
+	 */
+	@RequiresPermissions("workstockcontract:workStockContract:import")
+    @RequestMapping(value = "import/template")
+    public String importFileTemplate(HttpServletResponse response, RedirectAttributes redirectAttributes) {
+		try {
+            String fileName = "采购合同数据导入模板.xlsx";
+    		List<WorkStockContract> list = Lists.newArrayList(); 
+    		new ExportExcel("采购合同数据", WorkStockContract.class, 1).setDataList(list).write(response, fileName).dispose();
+    		return null;
+		} catch (Exception e) {
+			addMessage(redirectAttributes, "导入模板下载失败!失败信息:"+e.getMessage());
+		}
+		return "redirect:"+Global.getAdminPath()+"/workstockcontract/workStockContract/?repage";
+    }
+	
+	
+	/**
+	 * 选择供应商
+	 */
+	@RequestMapping(value = "selectsupplier")
+	public String selectsupplier(WorkSupplier supplier, String url, String fieldLabels, String fieldKeys, String searchLabel, String searchKey, HttpServletRequest request, HttpServletResponse response, Model model) {
+		supplier.setRemoveSign("1");//正常
+		Page<WorkSupplier> page = workSupplierService.findPage(new Page<WorkSupplier>(request, response), supplier);
+		try {
+			fieldLabels = URLDecoder.decode(fieldLabels, "UTF-8");
+			fieldKeys = URLDecoder.decode(fieldKeys, "UTF-8");
+			searchLabel = URLDecoder.decode(searchLabel, "UTF-8");
+			searchKey = URLDecoder.decode(searchKey, "UTF-8");
+		} catch (UnsupportedEncodingException e) {
+			e.printStackTrace();
+		}
+		model.addAttribute("labelNames", fieldLabels.split("\\|"));
+		model.addAttribute("labelValues", fieldKeys.split("\\|"));
+		model.addAttribute("fieldLabels", fieldLabels);
+		model.addAttribute("fieldKeys", fieldKeys);
+		model.addAttribute("url", url);
+		model.addAttribute("searchLabel", searchLabel);
+		model.addAttribute("searchKey", searchKey);
+		model.addAttribute("obj", supplier);
+		model.addAttribute("page", page);
+		return "modules/sys/gridselectsupplier";
+	}
+	/**
+	 * 强制撤销
+	 */
+	@RequestMapping("cancelInvalidate")
+	public String cancelInvalidate(WorkStockContract workStockContract,RedirectAttributes redirectAttributes){
+		workStockContractService.cancelInvalidate(workStockContract);
+		return "redirect:"+Global.getAdminPath()+"/workstockcontract/workStockContract/?repage";
+	}
+	@RequiresPermissions("workstockcontract:workStockContract:edit")
+	@RequestMapping(value = "complete")
+	public String complete(WorkStockContract workStockContract, RedirectAttributes redirectAttributes) {
+		workStockContractService.updateWorkReimbursementInfo(workStockContract);
+		workStockContract.setCompleteStatus("2");
+		workStockContractService.updateCompleteStatus(workStockContract);
+		addMessage(redirectAttributes, "该采购合同已完成");
+		return "redirect:"+Global.getAdminPath()+"/workstockcontract/workStockContract/?repage";
+	}
+	/**
+	 * 获取联系人名称
+	 * @return
+	 */
+	@RequestMapping(value = "getLinkName")
+	@ResponseBody
+	public String getLinkName() {
+		HashMap<Object, Object> map = Maps.newHashMap();
+		String obj = request.getParameter("obj");
+		WorkSupplier  workSupplier = workSupplierService.get(obj);
+		if(workSupplier!=null){
+			map.put("linkName",workSupplier.getLinkName());
+		}
+		return JsonMapper.toJsonString(map);
+	}
+}

+ 23 - 0
src/main/java/com/jeeplus/modules/worksupplier/dao/WorkSupplierDao.java

@@ -0,0 +1,23 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.worksupplier.dao;
+
+import com.jeeplus.common.persistence.CrudDao;
+import com.jeeplus.common.persistence.annotation.MyBatisDao;
+import com.jeeplus.modules.workinvoice.entity.WorkInvoice;
+import com.jeeplus.modules.worksupplier.entity.WorkSupplier;
+
+import java.util.List;
+
+/**
+ * 供应商管理DAO接口
+ * @author 供应商管理
+ * @version 2018-07-10
+ */
+@MyBatisDao
+public interface WorkSupplierDao extends CrudDao<WorkSupplier> {
+
+    public int updateSign(WorkSupplier workSupplier);
+    List<WorkSupplier> findClientInfoList(WorkSupplier workSupplier);
+}

+ 270 - 0
src/main/java/com/jeeplus/modules/worksupplier/entity/WorkSupplier.java

@@ -0,0 +1,270 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.worksupplier.entity;
+
+import com.google.common.collect.Lists;
+import com.jeeplus.modules.workclientinfo.entity.WorkClientAttachment;
+import org.hibernate.validator.constraints.URL;
+import org.hibernate.validator.constraints.CreditCardNumber;
+import org.hibernate.validator.constraints.Email;
+
+import com.jeeplus.common.persistence.DataEntity;
+import com.jeeplus.common.utils.excel.annotation.ExcelField;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 供应商管理Entity
+ * @author 供应商管理
+ * @version 2018-07-10
+ */
+public class WorkSupplier extends DataEntity<WorkSupplier> {
+	
+	private static final long serialVersionUID = 1L;
+	private String uscCode;		// 统一社会信用代码
+	private String officeId;		// 部门
+	private String companyId;		// 公司
+	private String name;		// 供应商名称
+	private String address;		// 公司地址
+	private String zipCode;		// 邮政编码
+	private String deputy;		// 法人代表
+	private String fax;		// 传真
+	private String website;		// 公司网站
+	private String registAddress;		// 公司注册地址
+	private String registPhone;		// 公司注册电话
+	private String bank;		// 开户银行
+	private String bankNumber;		// 开户账号
+	private String linkName;		// 联系人姓名
+	private String qq;		// qq号码
+	private String linkPhone;		// 联系人座机
+	private String linkMobile;		// 联系人手机
+	private String email;		// 电子邮箱
+	private String removeSign;		// 移除标记  1	正常 2	移除
+	private Date beginContractDate;		// 开始
+	private Date endContractDate;		// 结束
+	private List<WorkClientAttachment> workAttachments = Lists.newArrayList();
+	private String falt;		//
+
+	public String getBranchOffice() {
+		return branchOffice;
+	}
+
+	public void setBranchOffice(String branchOffice) {
+		this.branchOffice = branchOffice;
+	}
+
+	private String branchOffice;
+
+	public String getFalt() {
+		return falt;
+	}
+
+	public void setFalt(String falt) {
+		this.falt = falt;
+	}
+
+	public WorkSupplier() {
+		super();
+	}
+
+	public WorkSupplier(String id){
+		super(id);
+	}
+
+	@ExcelField(title="统一社会信用代码", align=2, sort=7)
+	public String getUscCode() {
+		return uscCode;
+	}
+
+	public void setUscCode(String uscCode) {
+		this.uscCode = uscCode;
+	}
+	
+	public String getOfficeId() {
+		return officeId;
+	}
+
+	public void setOfficeId(String officeId) {
+		this.officeId = officeId;
+	}
+	
+	public String getCompanyId() {
+		return companyId;
+	}
+
+	public List<WorkClientAttachment> getWorkAttachments() {
+		return workAttachments;
+	}
+
+	public void setWorkAttachments(List<WorkClientAttachment> workAttachments) {
+		this.workAttachments = workAttachments;
+	}
+
+	public void setCompanyId(String companyId) {
+		this.companyId = companyId;
+	}
+	
+	@ExcelField(title="供应商名称", align=2, sort=10)
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+	
+	@ExcelField(title="公司地址", align=2, sort=11)
+	public String getAddress() {
+		return address;
+	}
+
+	public Date getBeginContractDate() {
+		return beginContractDate;
+	}
+
+	public void setBeginContractDate(Date beginContractDate) {
+		this.beginContractDate = beginContractDate;
+	}
+
+	public Date getEndContractDate() {
+		return endContractDate;
+	}
+
+	public void setEndContractDate(Date endContractDate) {
+		this.endContractDate = endContractDate;
+	}
+
+	public void setAddress(String address) {
+		this.address = address;
+	}
+	
+	@ExcelField(title="邮政编码", align=2, sort=12)
+	public String getZipCode() {
+		return zipCode;
+	}
+
+	public void setZipCode(String zipCode) {
+		this.zipCode = zipCode;
+	}
+	
+	@ExcelField(title="法人代表", align=2, sort=13)
+	public String getDeputy() {
+		return deputy;
+	}
+
+	public void setDeputy(String deputy) {
+		this.deputy = deputy;
+	}
+	
+	@ExcelField(title="传真", align=2, sort=14)
+	public String getFax() {
+		return fax;
+	}
+
+	public void setFax(String fax) {
+		this.fax = fax;
+	}
+	
+	@ExcelField(title="公司网站", align=2, sort=15)
+	public String getWebsite() {
+		return website;
+	}
+
+	public void setWebsite(String website) {
+		this.website = website;
+	}
+	
+	@ExcelField(title="公司注册地址", align=2, sort=16)
+	public String getRegistAddress() {
+		return registAddress;
+	}
+
+	public void setRegistAddress(String registAddress) {
+		this.registAddress = registAddress;
+	}
+	
+	@ExcelField(title="公司注册电话", align=2, sort=17)
+	public String getRegistPhone() {
+		return registPhone;
+	}
+
+	public void setRegistPhone(String registPhone) {
+		this.registPhone = registPhone;
+	}
+	
+	@ExcelField(title="开户银行", align=2, sort=18)
+	public String getBank() {
+		return bank;
+	}
+
+	public void setBank(String bank) {
+		this.bank = bank;
+	}
+	
+	@ExcelField(title="开户账号", align=2, sort=19)
+	public String getBankNumber() {
+		return bankNumber;
+	}
+
+	public void setBankNumber(String bankNumber) {
+		this.bankNumber = bankNumber;
+	}
+	
+	@ExcelField(title="联系人姓名", align=2, sort=20)
+	public String getLinkName() {
+		return linkName;
+	}
+
+	public void setLinkName(String linkName) {
+		this.linkName = linkName;
+	}
+	
+	@ExcelField(title="qq号码", align=2, sort=21)
+	public String getQq() {
+		return qq;
+	}
+
+	public void setQq(String qq) {
+		this.qq = qq;
+	}
+	
+	@ExcelField(title="联系人座机", align=2, sort=22)
+	public String getLinkPhone() {
+		return linkPhone;
+	}
+
+	public void setLinkPhone(String linkPhone) {
+		this.linkPhone = linkPhone;
+	}
+	
+	@ExcelField(title="联系人手机", align=2, sort=23)
+	public String getLinkMobile() {
+		return linkMobile;
+	}
+
+	public void setLinkMobile(String linkMobile) {
+		this.linkMobile = linkMobile;
+	}
+	
+	@Email(message="电子邮箱必须为合法邮箱")
+	@ExcelField(title="电子邮箱", align=2, sort=24)
+	public String getEmail() {
+		return email;
+	}
+
+	public void setEmail(String email) {
+		this.email = email;
+	}
+	
+	@ExcelField(title="移除标记", align=2, sort=25,dictType = "remove_sign")
+	public String getRemoveSign() {
+		return removeSign;
+	}
+
+	public void setRemoveSign(String removeSign) {
+		this.removeSign = removeSign;
+	}
+	
+}

+ 107 - 0
src/main/java/com/jeeplus/modules/worksupplier/service/WorkSupplierService.java

@@ -0,0 +1,107 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.worksupplier.service;
+
+import java.util.List;
+
+import com.jeeplus.common.utils.StringUtils;
+import com.jeeplus.modules.sys.dao.OfficeDao;
+import com.jeeplus.modules.sys.entity.Office;
+import com.jeeplus.modules.sys.utils.UserUtils;
+import com.jeeplus.modules.workclientinfo.dao.WorkClientAttachmentDao;
+import com.jeeplus.modules.workclientinfo.entity.WorkClientAttachment;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.jeeplus.common.persistence.Page;
+import com.jeeplus.common.service.CrudService;
+import com.jeeplus.modules.worksupplier.entity.WorkSupplier;
+import com.jeeplus.modules.worksupplier.dao.WorkSupplierDao;
+
+/**
+ * 供应商管理Service
+ * @author 供应商管理
+ * @version 2018-07-10
+ */
+@Service
+@Transactional(readOnly = true)
+public class WorkSupplierService extends CrudService<WorkSupplierDao, WorkSupplier> {
+	@Autowired
+	private WorkClientAttachmentDao workClientAttachmentDao;
+	@Autowired
+	private WorkSupplierDao workSupplierDao;
+	@Autowired
+	private OfficeDao officeDao;
+
+	public WorkSupplier get(String id) {
+		WorkSupplier workSupplier = super.get(id);
+		//附件
+		WorkClientAttachment workClientAttachment = new WorkClientAttachment();
+		workClientAttachment.setAttachmentId(id);
+		workClientAttachment.setAttachmentFlag("101");
+		workSupplier.setWorkAttachments(workClientAttachmentDao.findList(workClientAttachment));
+		return workSupplier;
+	}
+	
+	public List<WorkSupplier> findList(WorkSupplier workSupplier) {
+		return super.findList(workSupplier);
+	}
+	
+	public Page<WorkSupplier> findPage(Page<WorkSupplier> page, WorkSupplier workSupplier) {
+		workSupplier.getSqlMap().put("dsf", dataScopeBranchOfficeFilter(workSupplier.getCurrentUser(), "s"));
+		workSupplier.setPage(page);
+		page.setList(findList(workSupplier));
+		return page;
+	}
+	
+	@Transactional(readOnly = false)
+	public void save(WorkSupplier workSupplier) {
+		super.save(workSupplier);
+		//附件信息
+		for (WorkClientAttachment workClientAttachment : workSupplier.getWorkAttachments()) {
+			if (workClientAttachment.getId() == null) {
+				continue;
+			}
+			if (WorkClientAttachment.DEL_FLAG_NORMAL.equals(workClientAttachment.getDelFlag())) {
+				workClientAttachment.setAttachmentId(workSupplier.getId());
+				workClientAttachment.setAttachmentFlag("101");
+				workClientAttachment.setAttachmentUser(UserUtils.getUser().getId());
+				if (StringUtils.isBlank(workClientAttachment.getId()) || "null".equals(workClientAttachment.getId())) {
+					workClientAttachment.preInsert();
+					workClientAttachmentDao.insert(workClientAttachment);
+				} else {
+					workClientAttachment.preUpdate();
+					workClientAttachmentDao.update(workClientAttachment);
+				}
+			} else {
+				workClientAttachmentDao.delete(workClientAttachment);
+			}
+		}
+	}
+	
+	@Transactional(readOnly = false)
+	public void delete(WorkSupplier workSupplier) {
+		super.delete(workSupplier);
+	}
+	@Transactional(readOnly = false)
+	public void updateSign(WorkSupplier workSupplier) {
+		workSupplierDao.updateSign(workSupplier);
+	}
+
+	public Page<WorkSupplier> findPageClientInfo(Page<WorkSupplier> page, WorkSupplier workSupplier) {
+		workSupplier.setPage(page);
+		page.setList(findClientInfoList(workSupplier));
+		return page;
+	}
+	public List<WorkSupplier> findClientInfoList(WorkSupplier workSupplier) {
+		Office office =officeDao.get(UserUtils.getSelectOffice().getId());
+		if(StringUtils.isNotBlank(office.getBranchOffice())){
+			workSupplier.setBranchOffice(office.getBranchOffice());
+		}else{
+			workSupplier.setCompanyId(UserUtils.getSelectCompany().getId());
+		}
+		return dao.findClientInfoList(workSupplier);
+	}
+}

+ 253 - 0
src/main/java/com/jeeplus/modules/worksupplier/web/WorkSupplierController.java

@@ -0,0 +1,253 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.worksupplier.web;
+
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.validation.ConstraintViolationException;
+
+import com.google.common.base.Strings;
+import com.jeeplus.modules.sys.entity.User;
+import com.jeeplus.modules.sys.utils.UserUtils;
+import org.apache.shiro.authz.annotation.Logical;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.servlet.mvc.support.RedirectAttributes;
+
+import com.google.common.collect.Lists;
+import com.jeeplus.common.utils.DateUtils;
+import com.jeeplus.common.utils.MyBeanUtils;
+import com.jeeplus.common.config.Global;
+import com.jeeplus.common.persistence.Page;
+import com.jeeplus.common.web.BaseController;
+import com.jeeplus.common.utils.StringUtils;
+import com.jeeplus.common.utils.excel.ExportExcel;
+import com.jeeplus.common.utils.excel.ImportExcel;
+import com.jeeplus.modules.worksupplier.entity.WorkSupplier;
+import com.jeeplus.modules.worksupplier.service.WorkSupplierService;
+
+/**
+ * 供应商管理Controller
+ * @author 供应商管理
+ * @version 2018-07-10
+ */
+@Controller
+@RequestMapping(value = "${adminPath}/worksupplier/workSupplier")
+public class WorkSupplierController extends BaseController {
+
+	@Autowired
+	private WorkSupplierService workSupplierService;
+	@Autowired
+	private HttpServletRequest request;
+	@ModelAttribute
+	public WorkSupplier get(@RequestParam(required=false) String id) {
+		WorkSupplier entity = null;
+		if (StringUtils.isNotBlank(id)){
+			entity = workSupplierService.get(id);
+		}
+		if (entity == null){
+			entity = new WorkSupplier();
+		}
+		return entity;
+	}
+	
+	/**
+	 * 列表页面
+	 */
+	@RequiresPermissions("worksupplier:workSupplier:list")
+	@RequestMapping(value = {"list", ""})
+	public String list(WorkSupplier workSupplier, HttpServletRequest request, HttpServletResponse response, Model model) {
+		Page<WorkSupplier> page = workSupplierService.findPage(new Page<WorkSupplier>(request, response), workSupplier);
+		model.addAttribute("page", page);
+		return "modules/worksupplier/workSupplierList";
+	}
+
+	/**
+	 * 查看,增加,编辑表单页面
+	 */
+	//@RequiresPermissions(value={"worksupplier:workSupplier:view","worksupplier:workSupplier:add","worksupplier:workSupplier:edit"},logical=Logical.OR)
+	@RequestMapping(value = "form")
+	public String form(WorkSupplier workSupplier, Model model) {
+		String view = "workSupplierForm";
+		String tabId = request.getParameter("tabId");
+		if("1".equals(tabId)){
+			view = "workSupplierView";
+		}
+		if(StringUtils.isBlank(workSupplier.getRemoveSign())){
+			workSupplier.setRemoveSign("1");
+		}
+		if(StringUtils.isBlank(workSupplier.getId())){
+			model.addAttribute("workSupplier", workSupplier);
+			return "modules/worksupplier/workSupplierForms";
+		}
+		model.addAttribute("workSupplier", workSupplier);
+		return "modules/worksupplier/"+view;
+	}
+
+	/**
+	 * 保存
+	 */
+	@RequiresPermissions(value={"worksupplier:workSupplier:add","worksupplier:workSupplier:edit"},logical=Logical.OR)
+	@RequestMapping(value = "save")
+	public String save(WorkSupplier workSupplier, Model model, RedirectAttributes redirectAttributes) throws Exception{
+		if (!beanValidator(model, workSupplier)){
+			return form(workSupplier, model);
+		}
+		User user = workSupplier.getCreateBy();
+		String submitter = "";
+		if(user != null){
+			submitter = user.getId();
+		}
+		if(!UserUtils.getUser().getId().equals(submitter) && !Strings.isNullOrEmpty(submitter)){
+			addMessage(redirectAttributes, "您不是创建人,无法修改");
+			return "redirect:"+Global.getAdminPath()+"/worksupplier/workSupplier/?repage";
+		}
+		if(!workSupplier.getIsNewRecord()){//编辑表单保存
+			WorkSupplier t = workSupplierService.get(workSupplier.getId());//从数据库取出记录的值
+			MyBeanUtils.copyBeanNotNull2Bean(workSupplier, t);//将编辑表单中的非NULL值覆盖数据库记录中的值
+			workSupplierService.save(t);//保存
+		}else{//新增表单保存
+			workSupplier.setCompanyId(UserUtils.getSelectOffice().getParentId());
+			workSupplier.setOfficeId(UserUtils.getSelectOffice().getId());
+			workSupplierService.save(workSupplier);//保存
+		}
+		addMessage(redirectAttributes, "保存成功");
+		return "redirect:"+Global.getAdminPath()+"/worksupplier/workSupplier/?repage";
+	}
+	
+	/**
+	 * 删除
+	 */
+	@RequiresPermissions("worksupplier:workSupplier:del")
+	@RequestMapping(value = "delete")
+	public String delete(WorkSupplier workSupplier, RedirectAttributes redirectAttributes) {
+		workSupplierService.delete(workSupplier);
+		addMessage(redirectAttributes, "删除成功");
+		return "redirect:"+Global.getAdminPath()+"/worksupplier/workSupplier/?repage";
+	}
+	@RequiresPermissions("worksupplier:workSupplier:edit")
+	@RequestMapping(value = "remove")
+	public String remove(WorkSupplier workSupplier, RedirectAttributes redirectAttributes) {
+		workSupplier.setRemoveSign("2");
+		workSupplierService.updateSign(workSupplier);
+		addMessage(redirectAttributes, "移除成功");
+		return "redirect:"+Global.getAdminPath()+"/worksupplier/workSupplier/?repage";
+	}
+	@RequiresPermissions("worksupplier:workSupplier:edit")
+	@RequestMapping(value = "live")
+	public String live(WorkSupplier workSupplier, RedirectAttributes redirectAttributes) {
+		workSupplier.setRemoveSign("1");
+		workSupplierService.updateSign(workSupplier);
+		addMessage(redirectAttributes, "恢复成功");
+		return "redirect:"+Global.getAdminPath()+"/worksupplier/workSupplier/?repage";
+	}
+	
+	/**
+	 * 批量删除
+	 */
+	@RequiresPermissions("worksupplier:workSupplier:del")
+	@RequestMapping(value = "deleteAll")
+	public String deleteAll(String ids, RedirectAttributes redirectAttributes) {
+		String idArray[] =ids.split(",");
+		for(String id : idArray){
+			workSupplierService.delete(workSupplierService.get(id));
+		}
+		addMessage(redirectAttributes, "删除成功");
+		return "redirect:"+Global.getAdminPath()+"/worksupplier/workSupplier/?repage";
+	}
+	
+	/**
+	 * 导出excel文件
+	 */
+	@RequiresPermissions("worksupplier:workSupplier:export")
+    @RequestMapping(value = "export", method=RequestMethod.POST)
+    public String exportFile(WorkSupplier workSupplier, HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) {
+		try {
+            String fileName = ""+DateUtils.getDate("yyyyMMddHHmmss")+".xlsx";
+            Page<WorkSupplier> page = workSupplierService.findPage(new Page<WorkSupplier>(request, response, -1), workSupplier);
+    		new ExportExcel("", WorkSupplier.class).setDataList(page.getList()).write(response, fileName).dispose();
+    		return null;
+		} catch (Exception e) {
+			addMessage(redirectAttributes, "导出记录失败!失败信息:"+e.getMessage());
+		}
+		return "redirect:"+Global.getAdminPath()+"/worksupplier/workSupplier/?repage";
+    }
+
+	/**
+	 * 导入Excel数据
+
+	 */
+	@RequiresPermissions("worksupplier:workSupplier:import")
+    @RequestMapping(value = "import", method=RequestMethod.POST)
+    public String importFile(MultipartFile file, RedirectAttributes redirectAttributes) {
+		try {
+			int successNum = 0;
+			int failureNum = 0;
+			StringBuilder failureMsg = new StringBuilder();
+			ImportExcel ei = new ImportExcel(file, 1, 0);
+			List<WorkSupplier> list = ei.getDataList(WorkSupplier.class);
+			for (WorkSupplier workSupplier : list){
+				try{
+					workSupplierService.save(workSupplier);
+					successNum++;
+				}catch(ConstraintViolationException ex){
+					failureNum++;
+				}catch (Exception ex) {
+					failureNum++;
+				}
+			}
+			if (failureNum>0){
+				failureMsg.insert(0, ",失败 "+failureNum+" 条记录。");
+			}
+			addMessage(redirectAttributes, "已成功导入 "+successNum+" 条记录"+failureMsg);
+		} catch (Exception e) {
+			addMessage(redirectAttributes, "导入失败!失败信息:"+e.getMessage());
+		}
+		return "redirect:"+Global.getAdminPath()+"/worksupplier/workSupplier/?repage";
+    }
+	
+	/**
+	 * 下载导入数据模板
+	 */
+	@RequiresPermissions("worksupplier:workSupplier:import")
+    @RequestMapping(value = "import/template")
+    public String importFileTemplate(HttpServletResponse response, RedirectAttributes redirectAttributes) {
+		try {
+            String fileName = "数据导入模板.xlsx";
+    		List<WorkSupplier> list = Lists.newArrayList(); 
+    		new ExportExcel("供应商管理数据", WorkSupplier.class, 1).setDataList(list).write(response, fileName).dispose();
+    		return null;
+		} catch (Exception e) {
+			addMessage(redirectAttributes, "导入模板下载失败!失败信息:"+e.getMessage());
+		}
+		return "redirect:"+Global.getAdminPath()+"/worksupplier/workSupplier/?repage";
+    }
+	@ResponseBody
+	@RequestMapping(value = "validateUscCode")
+	public boolean validateMobileExist(String uscCode, HttpServletResponse response, Model model) {
+		WorkSupplier workSupplier =  workSupplierService.findUniqueByProperty("usc_code", uscCode);
+		String id = request.getParameter("ids");
+		if(workSupplier != null){
+			if(StringUtils.isNotBlank(id)){
+				if(!id.equals(workSupplier.getId())){
+					return false;
+				}else{
+					return true;
+				}
+			}
+			return false;
+		}else{
+			return true;
+		}
+	}
+	
+	
+
+}

+ 41 - 0
src/main/java/com/jeeplus/modules/workvisa/dao/WorkVisaDao.java

@@ -0,0 +1,41 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workvisa.dao;
+
+import com.jeeplus.modules.sys.entity.Workattachment;
+import com.jeeplus.modules.workfullmanage.entity.WorkFullManage;
+import java.util.List;
+import com.jeeplus.common.persistence.CrudDao;
+import com.jeeplus.common.persistence.annotation.MyBatisDao;
+import com.jeeplus.modules.workvisa.entity.WorkVisa;
+
+/**
+ * 工程签证DAO接口
+ * @author liuw
+ * @version 2017-10-31
+ */
+@MyBatisDao
+public interface WorkVisaDao extends CrudDao<WorkVisa> {
+
+	public List<WorkFullManage> findListByfullManage(WorkFullManage fullManage);
+
+	public int getCount(String fullManageId);
+
+	public List<WorkVisa> findListByWF(WorkVisa workVisa);
+
+	List<Workattachment> getListOfAttachment(String attachmentId);
+	/**
+	 * 更新流程实例ID
+	 * @param workVisa
+	 * @return
+	 */
+	public int updateProcessInstanceId(WorkVisa workVisa);
+	/**
+	 * 根据流程实例ID获取Leave
+	 * @param processInstanceId
+	 * @return
+	 */
+	public WorkVisa getByProcessInstanceId(String processInstanceId);
+
+}

+ 262 - 0
src/main/java/com/jeeplus/modules/workvisa/entity/WorkVisa.java

@@ -0,0 +1,262 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workvisa.entity;
+
+import com.jeeplus.common.persistence.ActEntity;
+import com.jeeplus.modules.sys.entity.Workattachment;
+import com.jeeplus.modules.workfullmanage.entity.WorkFullManage;
+
+import com.jeeplus.common.persistence.DataEntity;
+import com.jeeplus.common.utils.excel.annotation.ExcelField;
+import org.activiti.engine.history.HistoricProcessInstance;
+import org.activiti.engine.repository.ProcessDefinition;
+import org.activiti.engine.runtime.ProcessInstance;
+import org.activiti.engine.task.Task;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 工程签证Entity
+ * @author liuw
+ * @version 2017-10-31
+ */
+public class WorkVisa extends ActEntity<WorkVisa> {
+	
+	private static final long serialVersionUID = 1L;
+	private String initiateClient;		// 发起单位
+	private String cprojectName;		// 单位工程名称
+	private String constructionExample;		// 施工标段
+	private String visaNumber;		// 签证单编号
+	private String visaArea;		// 签证范围
+	private String theme;		// 主题内容
+	private String visaContent;		// 签证单主要内容
+	private String replySuggest;		// 审价批复意见
+	private WorkFullManage fullManage;		// 全过程管理项目
+	private String status;		// 项目状态  1暂存2审核中3未通过4已通过5已撤销
+	private String companyId;		// 公司id
+	private String officeId;
+	private Boolean processEnded;            //流程是否走到了结束状态(结束:false,未结束:true)
+	public String getOfficeId() {
+		return officeId;
+	}
+
+	public void setOfficeId(String officeId) {
+		this.officeId = officeId;
+	}
+	//work_attachment中attachment_flag = 37 工程签证附件
+	private Workattachment attachmentFile;     //附件
+	//private List<Workattachment> workattachmentList = new ArrayList<>();
+
+
+
+	private List<Workattachment> workAttachments = new ArrayList<>();
+	private String name;			//查看修改标识
+	private String processInstanceId; // 流程实例编号
+	// -- 临时属性 --//
+	// 流程任务
+	private Task task;
+	private Map<String, Object> variables;
+	// 运行中的流程实例
+	private ProcessInstance processInstance;
+	// 历史的流程实例
+	private HistoricProcessInstance historicProcessInstance;
+	// 流程定义
+	private ProcessDefinition processDefinition;
+
+	public Task getTask() {
+		return task;
+	}
+
+	public void setTask(Task task) {
+		this.task = task;
+	}
+
+	public Map<String, Object> getVariables() {
+		return variables;
+	}
+
+	public void setVariables(Map<String, Object> variables) {
+		this.variables = variables;
+	}
+
+	public Boolean getProcessEnded() {
+		return processEnded;
+	}
+
+	public void setProcessEnded(Boolean processEnded) {
+		this.processEnded = processEnded;
+	}
+
+	public ProcessInstance getProcessInstance() {
+		return processInstance;
+	}
+
+	public void setProcessInstance(ProcessInstance processInstance) {
+		this.processInstance = processInstance;
+	}
+
+	public HistoricProcessInstance getHistoricProcessInstance() {
+		return historicProcessInstance;
+	}
+
+	public void setHistoricProcessInstance(HistoricProcessInstance historicProcessInstance) {
+		this.historicProcessInstance = historicProcessInstance;
+	}
+
+	public ProcessDefinition getProcessDefinition() {
+		return processDefinition;
+	}
+
+	public void setProcessDefinition(ProcessDefinition processDefinition) {
+		this.processDefinition = processDefinition;
+	}
+
+
+	public String getProcessInstanceId() {
+		return processInstanceId;
+	}
+
+	public void setProcessInstanceId(String processInstanceId) {
+		this.processInstanceId = processInstanceId;
+	}
+
+	/*public List<Workattachment> getWorkattachmentList() {
+		return workattachmentList;
+	}
+
+	public void setWorkattachmentList(List<Workattachment> workattachmentList) {
+		this.workattachmentList = workattachmentList;
+	}*/
+	public List<Workattachment> getWorkAttachments() {
+		return workAttachments;
+	}
+
+	public void setWorkAttachments(List<Workattachment> workAttachments) {
+		this.workAttachments = workAttachments;
+	}
+	public String getCompanyId() {
+		return companyId;
+	}
+
+	public void setCompanyId(String companyId) {
+		this.companyId = companyId;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	public Workattachment getAttachmentFile() {
+		return attachmentFile;
+	}
+
+	public void setAttachmentFile(Workattachment attachmentFile) {
+		this.attachmentFile = attachmentFile;
+	}
+
+	public WorkVisa() {
+		super();
+	}
+
+	public WorkVisa(String id){
+		super(id);
+	}
+
+	@ExcelField(title="发起单位", align=2, sort=7)
+	public String getInitiateClient() {
+		return initiateClient;
+	}
+
+	public void setInitiateClient(String initiateClient) {
+		this.initiateClient = initiateClient;
+	}
+	
+	@ExcelField(title="单位工程名称", align=2, sort=8)
+	public String getCprojectName() {
+		return cprojectName;
+	}
+
+	public void setCprojectName(String cprojectName) {
+		this.cprojectName = cprojectName;
+	}
+	
+	@ExcelField(title="施工标段", align=2, sort=9)
+	public String getConstructionExample() {
+		return constructionExample;
+	}
+
+	public void setConstructionExample(String constructionExample) {
+		this.constructionExample = constructionExample;
+	}
+	
+	@ExcelField(title="签证单编号", align=2, sort=10)
+	public String getVisaNumber() {
+		return visaNumber;
+	}
+
+	public void setVisaNumber(String visaNumber) {
+		this.visaNumber = visaNumber;
+	}
+	
+	@ExcelField(title="签证范围", align=2, sort=11)
+	public String getVisaArea() {
+		return visaArea;
+	}
+
+	public void setVisaArea(String visaArea) {
+		this.visaArea = visaArea;
+	}
+	
+	@ExcelField(title="主题内容", align=2, sort=12)
+	public String getTheme() {
+		return theme;
+	}
+
+	public void setTheme(String theme) {
+		this.theme = theme;
+	}
+	
+	@ExcelField(title="签证单主要内容", align=2, sort=13)
+	public String getVisaContent() {
+		return visaContent;
+	}
+
+	public void setVisaContent(String visaContent) {
+		this.visaContent = visaContent;
+	}
+	
+	@ExcelField(title="审价批复意见", align=2, sort=14)
+	public String getReplySuggest() {
+		return replySuggest;
+	}
+
+	public void setReplySuggest(String replySuggest) {
+		this.replySuggest = replySuggest;
+	}
+	
+	@ExcelField(title="全过程管理项目", align=2, sort=15)
+	public WorkFullManage getFullManage() {
+		return fullManage;
+	}
+
+	public void setFullManage(WorkFullManage fullManage) {
+		this.fullManage = fullManage;
+	}
+	
+	@ExcelField(title="项目状态", align=2, sort=16)
+	public String getStatus() {
+		return status;
+	}
+
+	public void setStatus(String status) {
+		this.status = status;
+	}
+	
+}

+ 550 - 0
src/main/java/com/jeeplus/modules/workvisa/service/WorkVisaService.java

@@ -0,0 +1,550 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workvisa.service;
+
+import java.io.UnsupportedEncodingException;
+import java.util.*;
+
+import com.google.common.collect.Maps;
+import com.jeeplus.common.utils.DateUtils;
+import com.jeeplus.common.utils.MenuStatusEnum;
+import com.jeeplus.common.utils.StringUtils;
+
+import com.jeeplus.common.config.Global;
+import com.jeeplus.common.oss.OSSClientUtil;
+import com.jeeplus.modules.act.service.ActTaskService;
+import com.jeeplus.modules.act.utils.ActUtils;
+import com.jeeplus.modules.sys.entity.Role;
+import com.jeeplus.modules.sys.entity.User;
+import com.jeeplus.modules.sys.entity.Workattachment;
+import com.jeeplus.modules.sys.service.OfficeService;
+import com.jeeplus.modules.sys.service.WorkattachmentService;
+import com.jeeplus.modules.sys.utils.UserUtils;
+import com.jeeplus.modules.workactivity.entity.Activity;
+import com.jeeplus.modules.workactivity.entity.WorkActivityProcess;
+import com.jeeplus.modules.workactivity.service.ActivityService;
+import com.jeeplus.modules.workactivity.service.WorkActivityProcessService;
+import com.jeeplus.modules.workactivitymenu.entity.WorkActivityMenu;
+import com.jeeplus.modules.workactivitymenu.service.WorkActivityMenuService;
+import com.jeeplus.modules.workclientinfo.entity.WorkClientAttachment;
+import com.jeeplus.modules.workfullmanage.entity.WorkFullRecord;
+import com.jeeplus.modules.workprojectnotify.entity.WorkProjectNotify;
+import com.jeeplus.modules.workprojectnotify.service.WorkProjectNotifyService;
+import com.jeeplus.modules.workprojectnotify.util.UtilNotify;
+import org.activiti.engine.ActivitiObjectNotFoundException;
+import org.activiti.engine.IdentityService;
+import org.activiti.engine.RuntimeService;
+import org.activiti.engine.runtime.ProcessInstance;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.jeeplus.modules.workfullmanage.entity.WorkFullManage;
+import com.jeeplus.common.persistence.Page;
+import com.jeeplus.common.service.CrudService;
+import com.jeeplus.modules.workvisa.entity.WorkVisa;
+import com.jeeplus.modules.workvisa.dao.WorkVisaDao;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.MultipartHttpServletRequest;
+
+/**
+ * 工程签证Service
+ * @author liuw
+ * @version 2017-10-31
+ */
+@Service
+@Transactional(readOnly = true)
+public class WorkVisaService extends CrudService<WorkVisaDao, WorkVisa> {
+	@Autowired
+	private WorkattachmentService workattachmentService;
+	@Autowired
+	private IdentityService identityService;
+	@Autowired
+	private RuntimeService runtimeService;
+	@Autowired
+	private WorkActivityMenuService workActivityMenuService;
+	@Autowired
+	private WorkActivityProcessService workActivityProcessService;
+	@Autowired
+	private ActivityService activityService;
+
+	@Autowired
+	private ActTaskService actTaskService;
+	@Autowired
+	private WorkProjectNotifyService workProjectNotifyService;
+	@Autowired
+	private WorkVisaDao workVisaDao;
+	@Autowired
+	private OfficeService officeService;
+
+
+	public WorkVisa get(String id) {
+		//return super.get(id);
+
+		WorkVisa workVisa = super.get(id);
+
+		Workattachment workattachment = new Workattachment();
+		workattachment.setAttachmentId(id);
+		//workattachment.setAttachmentFlag("37");
+		workVisa.setWorkAttachments(workattachmentService.findList(workattachment));
+
+		return workVisa;
+	}
+	
+	public List<WorkVisa> findList(WorkVisa workVisa) {
+		return super.findList(workVisa);
+	}
+
+	public int findCount(String fullManageId){return workVisaDao.getCount(fullManageId);}
+
+	public Page<WorkVisa> findPage(Page<WorkVisa> page, WorkVisa workVisa) {
+		workVisa.getSqlMap().put("dsf", dataScopeFilter(workVisa.getCurrentUser(), "o", "u","s", MenuStatusEnum.END.getValue()));
+		return super.findPage(page, workVisa);
+	}
+
+	public List<WorkVisa> findListByWF(WorkVisa workVisa){
+		return workVisaDao.findListByWF(workVisa);
+	}
+	
+	/*@Transactional(readOnly = false)
+	public void save(WorkVisa workVisa,MultipartFile attachment_file) {
+		super.save(workVisa);
+		uploadattachment(attachment_file,workVisa);
+	}*/
+	@Transactional(readOnly = false)
+	public void save(WorkVisa workVisa) {
+		super.save(workVisa);
+	}
+
+	@Transactional(readOnly = false)
+	public void delete(WorkVisa workVisa) {
+		super.delete(workVisa);
+	}
+	
+	public Page<WorkFullManage> findPageByfullManage(Page<WorkFullManage> page, WorkFullManage fullManage) {
+		fullManage.setPage(page);
+		page.setList(dao.findListByfullManage(fullManage));
+		return page;
+	}
+	public Page<WorkVisa> findPageByfullMg(Page<WorkVisa> page, WorkVisa workVisa) {
+		workVisa.setPage(page);
+		page.setList(dao.findListByWF(workVisa));
+		return page;
+	}
+	@Transactional(readOnly = false)
+	public void update(WorkVisa workVisa) {
+		workVisa.preUpdate();
+		dao.update(workVisa);
+	}
+	/* * 审核审批保存
+     * @param testAudit
+     */
+	@Transactional(readOnly = false)
+	public String auditSave(WorkVisa workVisa) {
+		try {
+		String userId = UserUtils.getUser().getId();
+		actTaskService.claim(workVisa.getAct().getTaskId(), userId);
+		String comment = "";
+		if (workVisa.getStatus().equals("3")){
+			comment = ("yes".equals(workVisa.getAct().getFlag())?"[重新申请] ":"[已撤销] ");
+		}else {
+			comment = ("yes".equals(workVisa.getAct().getFlag())?"[同意] ":"[驳回] ")+workVisa.getAct().getComment();
+		}
+		// 设置意见
+		workVisa.getAct().setComment(comment);
+		System.out.println("comment================="+workVisa.getAct().getComment());
+		WorkProjectNotify workProjectNotify = new WorkProjectNotify();
+		//String comment = ("yes".equals(workVisa.getAct().getFlag())?"[同意] ":"[驳回] ")+workVisa.getAct().getComment();
+		//workVisa.getAct().setComment(("yes".equals(workVisa.getAct().getFlag())?"[同意] ":"[驳回] ")+workVisa.getAct().getComment());
+		/*try {
+			workVisa.getAct().setComment(new String(comment.getBytes("UTF-8")));
+		} catch (UnsupportedEncodingException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}*/
+
+		// 对不同环节的业务逻辑进行操作
+		String taskDefKey = workVisa.getAct().getTaskDefKey();
+		workProjectNotify.setUser(workVisa.getCreateBy());
+		workProjectNotify.setRemarks("待通知");
+		System.out.println("taskDefKey====================="+taskDefKey);
+		//业务逻辑对应的条件表达式
+		String exp = "";
+			String str = "";
+			//WorkActivityMenu workActivityMenu = workActivityMenuService.findByParentAndOffice("9574872f45b84acd89jjj1e66a3db2c8",UserUtils.getSelectOffice());
+			List<Activity> activitieList = activityService.getByProcessInstanceId(workVisa.getProcessInstanceId());
+			WorkActivityMenu workActivityMenu = new WorkActivityMenu();
+			if (activitieList!=null && activitieList.size()!=0){
+				workActivityMenu.setProcessType(activitieList.get(0).getProcessKey());
+				workActivityMenu.setActivities(activitieList);
+			}
+
+			WorkActivityProcess workActivityProcess = new WorkActivityProcess();
+			WorkActivityProcess selectProcess = new WorkActivityProcess();
+			selectProcess.setProcessInstanceId(workVisa.getProcessInstanceId());
+			List<WorkActivityProcess> workActivityProcesses = workActivityProcessService.findList(selectProcess);
+			workVisa.setStatus("2");
+			String taskCount = "";
+			List<Activity> activities = workActivityMenu.getActivities();
+			int key = 0;
+			if (StringUtils.isNotBlank(workActivityMenu.getProcessType()) && !workActivityMenu.getProcessType().equals("workVisa")) {
+				key= 1;
+					for (int i =0;i<workActivityProcesses.size();i++){
+						WorkActivityProcess activityProcess = workActivityProcesses.get(i);
+						//String count = taskDefKey.replace("task","");
+						String count = taskDefKey.replace("task","").replace("audit","");
+						if (taskDefKey.contains("audit")&& (activityProcess.getCount()+"").contains(count)){
+							taskCount = count;
+							exp = "pass";
+							workActivityProcess.setId("");
+							workActivityProcess.setCount(0);
+							if (!"yes".equals(workVisa.getAct().getFlag())) {
+								workVisa.setStatus("5");
+								str = "工程签证审核:已撤销!";
+								workActivityProcess.setIsApproval("2");
+							}else {
+								str = "工程签证审核:重新申请!";
+								workActivityProcess.setIsApproval("1");
+							}
+						}else if ((activityProcess.getCount()+"").contains(count)){
+							taskCount = count;
+							workActivityProcess = activityProcess;
+							if (!workActivityProcess.getIsApproval().equals("0")){
+								workActivityProcess.setId("");
+							}
+							exp = "pass";
+							if (!"yes".equals(workVisa.getAct().getFlag())) {
+								workVisa.setStatus("3");
+								str = "工程签证审核:被驳回!";
+								workActivityProcess.setIsApproval("2");
+								String returnBack = "-1";
+								for (Activity activity:activities){
+									if(activity.getCount()==Integer.parseInt(count)){
+										returnBack = activity.getReturnBack();
+										break;
+									}
+								}
+								if (returnBack.equals("0")) {
+									workActivityProcess.setId("");
+								}
+								workVisa.setRemarks("重新申请");
+							}else {
+								str = "工程签证审核:待审批!";
+								workActivityProcess.setIsApproval("1");
+							}
+						}
+					}
+				}
+			else {
+				for (int i =0;i<workActivityProcesses.size();i++) {
+					workActivityMenu.setId(workActivityProcesses.get(0).getId());
+					workActivityMenu.setProcessType("workVisa");
+					WorkActivityProcess activityProcess = workActivityProcesses.get(i);
+					String count = activityProcess.getCount() + "";
+					//workActivityProcess = activityProcess;
+					if (!activityProcess.getIsApproval().equals("0")){
+						workActivityProcess.setId("");
+					}
+					taskCount = "1";// 默认流程只有一个审批环节
+					// 审核环节
+					if ("audit".equals(taskDefKey) && count.contains("1")) {
+						workActivityProcess = activityProcess;
+						exp = "pass";
+						if (!"yes".equals(workVisa.getAct().getFlag())) {
+							workActivityProcess.setIsApproval("2");
+							workProjectNotify.setRemarks("重新申请");
+							workVisa.setStatus("3");
+							workProjectNotify.setTitle("工程签证审核被驳回!");
+						} else {
+							workActivityProcess.setIsApproval("1");
+							workVisa.setStatus("4");
+						}
+					} else if ("audits".equals(taskDefKey)&& count.contains("0")) {
+						workActivityProcess.setCount(0);
+						if ("yes".equals(workVisa.getAct().getFlag())) {
+							workActivityProcess.setIsApproval("1");
+							workProjectNotify.setTitle("工程签证重新申请!");
+							Role role = UserUtils.getSelectRole().get(0);
+							StringBuffer buffer = DateUtils.getByEnnme(role.getEnname());
+							buffer.append("bmzr");
+							workProjectNotify.setNotifyRole(buffer.toString());
+							workProjectNotify.setUser(new User());
+							workProjectNotify.setRemarks("待审批");
+							workVisa.setStatus("2");
+						} else {
+							workActivityProcess.setIsApproval("2");
+							workVisa.setStatus("5");
+						}
+						exp = "pass";
+					}
+				}
+
+				// 未知环节,直接返回
+			}
+		/*	workActivityProcess.setRemarks(comment);
+			workActivityProcess.setProcessInstanceId(workVisa.getProcessInstanceId());
+			workActivityProcess.setProcessKey(workActivityMenu.getProcessType());
+			if (workActivityProcess!=null && StringUtils.isNotBlank(workActivityProcess.getIsApproval())){
+				workActivityProcessService.save(workActivityProcess);
+			}*/
+		// 提交流程任务
+		Map<String, Object> vars = Maps.newHashMap();
+		vars.put(exp, "yes".equals(workVisa.getAct().getFlag()) ?true : false );
+		System.out.println("vars============"+vars.toString());
+			workActivityProcessService.updateProcess(workActivityProcess,workActivityMenu,key,taskCount,workVisa.getProcessInstanceId(),taskDefKey,"audits",workVisa.getAct().getFlag(),comment, activities);
+			// 提交流程任务
+			actTaskService.complete(workVisa.getAct().getTaskId(), workVisa.getAct().getProcInsId(), workVisa.getAct().getComment(), vars);
+			boolean state = actTaskService.isProcessEnd(workVisa.getAct().getProcInsId());
+			WorkProjectNotify projectNotify = new WorkProjectNotify();
+			projectNotify.setNotifyId(workVisa.getId());
+			workProjectNotifyService.readByNotifyId(projectNotify);
+			workProjectNotify.setNotifyId(workVisa.getId());
+			workProjectNotify.setCompanyId(workVisa.getCompanyId());
+			workProjectNotify.setContent(workVisa.getAct().getComment());
+			workProjectNotify.setType("22");
+			workProjectNotify.setStatus("0");
+			WorkProjectNotify notify = new WorkProjectNotify();
+			notify.setNotifyId(workVisa.getId());
+			workProjectNotifyService.readByNotifyId(notify);
+			if (!state){
+				workVisa.setRemarks("待通知");
+				if ("yes".equals(workVisa.getAct().getFlag())){
+					workVisa.setStatus("4");
+					workProjectNotify.setTitle("工程签证已通过!");
+					Set<String> set = new HashSet<>();
+					set.add(workVisa.getCreateBy().getId());
+					for (String user :set){
+						if (StringUtils.isNotBlank(user)) {
+							workProjectNotify.setUser(new User(user));
+							workProjectNotify.preInsert();
+							workProjectNotifyService.insert(workProjectNotify);
+						}
+					}
+				}else {
+					if (!workVisa.getStatus().equals("5")) {
+						workVisa.setStatus("3");
+						workProjectNotify.setTitle("工程签证被驳回!");
+						workProjectNotify = UtilNotify
+								.saveNotify(workVisa.getId(),
+										workVisa.getCreateBy(),
+										workVisa.getCompanyId(),
+										str,
+										workVisa.getAct().getComment(),
+										"22",
+										"0",
+										"待通知",
+										"");
+						workProjectNotifyService
+								.save(workProjectNotify);
+					}
+				}
+			}else {
+				if (StringUtils.isNotBlank(workActivityMenu.getProcessType()) && !workActivityMenu.getProcessType().equals("workVisa")) {
+					workProjectNotify = UtilNotify
+							.saveNotify(workVisa.getId(),
+									new User(),
+									workVisa.getCompanyId(),
+									str,
+									workVisa.getAct().getComment(),
+									"22",
+									"0",
+									"待审批",
+									"");
+					String count = taskDefKey.replace("audit","").replace("task","");
+
+					workProjectNotify = activityService.getByFlagAndTaskDefKey(
+							activities,
+							workProjectNotify,
+							taskDefKey,
+							workVisa.getAct().getFlag(),
+							count,
+							workVisa.getCreateBy());
+					workProjectNotifyService
+							.save(workProjectNotify);
+				}else {
+
+					if (!workVisa.getStatus().equals("5")) {
+						workProjectNotifyService.save(workProjectNotify);
+					}
+				}
+			}
+			workVisa.preUpdate();
+			this.update(workVisa);
+			return "保存审核意见成功!";
+		}catch (ActivitiObjectNotFoundException e){
+			logger.error("ActivitiObjectNotFoundException e:"+e);
+			return "流程已审批,不能重新审批!";
+		}catch (Exception e){
+			logger.error("Exception e:"+e);
+			return "保存审核意见失败!!";
+		}
+	}
+	/**
+	 * 启动流程
+	 * @param
+	 */
+	@Transactional(readOnly = false)
+	public void startProcess(WorkVisa workVisa, Map<String, Object> variables) {
+		// 用来设置启动流程的人员ID,引擎会自动把用户ID保存到activiti:initiator中
+		identityService.setAuthenticatedUserId(workVisa.getCurrentUser().getId());
+		WorkActivityMenu workActivityMenu = workActivityMenuService.findByParentAndOffice("9574872f45b84acd89jjj1e66a3db2c8",officeService.get(workVisa.getOfficeId()));
+		// 启动流程
+		String businessKey = workVisa.getId().toString();
+		String processType = workActivityMenu.getProcessType();
+		StringBuffer buffer = new StringBuffer();
+		Activity activity = new Activity();
+		if (StringUtils.isNotBlank(workActivityMenu.getId())){
+			workActivityMenu = workActivityMenuService.get(workActivityMenu.getId());
+			List<Activity> activities = workActivityMenu.getActivities();
+			for (Activity a:activities){
+				if (a.getDelFlag().equals("0") && a.getCount() == 1){
+					activity = a;
+				}
+			}
+			buffer.append(activity.getRole().getEnname());
+			variables.put("type", workActivityMenu.getProcessType());
+		}else {
+			processType= "workVisa";
+			variables.put("type", "workVisa");
+			Role role = UserUtils.getSelectRole().get(0);
+			buffer = DateUtils.getByEnnme(role.getEnname());
+			buffer.append("bmzr");
+			variables.put("bmzr", buffer.toString());
+		}
+
+		variables.put("busId", businessKey);
+		variables.put("title", workVisa.getRemarks());//设置标题;
+		ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(processType, businessKey, variables);
+		workVisa.setProcessInstance(processInstance);
+		// 更新流程实例ID
+		workVisa.setProcessInstanceId(processInstance.getId());
+		dao.updateProcessInstanceId(workVisa);
+
+		List<Activity> list= workActivityMenu.getActivities();
+		if (list!=null && list.size()!=0){
+			workActivityProcessService.saveList(list,processInstance.getId());
+		}else {
+			WorkActivityProcess workActivityProcess = new WorkActivityProcess();
+			workActivityProcess.setProcessKey("workVisa");
+			workActivityProcess.setCount(1);
+			workActivityProcess.setProcessInstanceId(processInstance.getId());
+			workActivityProcess.setIsApproval("0");
+			workActivityProcess.setActivity(new Activity("9574872f45b84acd893010eggg0db2c8"));
+			workActivityProcessService.save(workActivityProcess);
+		}
+
+		WorkProjectNotify workProjectNotify = new WorkProjectNotify();
+		workProjectNotify.setTitle("工程签证单-审批申请");
+		workProjectNotify.setNotifyId(workVisa.getId());
+		workProjectNotify.setNotifyRole(buffer.toString());
+		workProjectNotify.setCompanyId(workVisa.getCompanyId());
+		workProjectNotify.setContent(UserUtils.get(workVisa.getCreateBy().getId()).getName()+"发起工程签证单-审核,请审批!");
+		workProjectNotify.setType("22");
+		workProjectNotify.setStatus("0");
+		workProjectNotify.setRemarks("待审批");
+		if(workActivityMenu!=null&&StringUtils.isNotBlank(workActivityMenu.getId())&&StringUtils.isNotBlank(activity.getId())){
+			//角色审批
+			if(StringUtils.isNotBlank(activity.getRole().getEnname())){
+				workProjectNotify.setNotifyRole(buffer.toString());
+			}
+			//人员审批
+			if(StringUtils.isNotBlank(activity.getUser().getId())){
+				workProjectNotify.setUser(new User(activity.getUser().getId()));
+			}
+		}else {
+			workProjectNotify.setNotifyRole(buffer.toString());
+		}
+		workProjectNotifyService.save(workProjectNotify);
+	}
+	//上传附件
+	@Transactional(readOnly = false)
+	public String uploadEvaludate(MultipartHttpServletRequest multiRequest) {
+		String userId = multiRequest.getParameter("id");
+		OSSClientUtil ossUtil = new OSSClientUtil();
+		Iterator<String> fileNames = multiRequest.getFileNames();
+		while(fileNames.hasNext()){
+			MultipartFile file = multiRequest.getFile(fileNames.next());
+			String fileName = file.getOriginalFilename();
+			String fileType = fileName.substring(fileName.lastIndexOf(".")+1);
+			if(file != null && !file.isEmpty()){
+				String aliyunPath = ossUtil.uploadFile2OSS(file, "workVisa");
+				Workattachment workattachment = new Workattachment();
+				workattachment.setUrl(aliyunPath);
+				workattachment.setType(fileType);
+				workattachment.setAttachmentId(userId);
+				workattachment.setAttachmentUser(UserUtils.getUser().getId());
+				workattachment.setAttachmentName(fileName);
+				workattachment.setAttachmentFlag("0");
+				workattachmentService.save(workattachment);
+				return workattachment.getId();
+			}
+		}
+		return null ;
+	}
+
+	/**
+	 * 获取流程详细信息
+	 * @param processInstanceId
+	 */
+	@SuppressWarnings("unchecked")
+	public WorkVisa getByProcessInstanceId(String processInstanceId) {
+		WorkVisa workVisa = dao.getByProcessInstanceId(processInstanceId);
+		return workVisa;
+	}
+
+	//删除附件
+	//阿里云文件地址http://gangwan-app.oss-cn-hangzhou.aliyuncs.com/attachment-file/workBidingDocument/3fcf03e37b3ba0fd5c7821998e392395.doc
+	//其中阿里云删除接口所需的参数 key 指的是 attachment-file/workBidingDocument/3fcf03e37b3ba0fd5c7821998e392395.doc
+	@Transactional(readOnly = false)
+	public void deleteFileFromAliyun(Workattachment workattachment) {
+		String url = workattachment.getUrl();
+		if(StringUtils.isNotBlank(url)){
+			String aliyunUrl = Global.getAliyunUrl();
+			String aliDownloadUrl = Global.getAliDownloadUrl();
+			String cons = "";
+			if (url.contains(aliyunUrl)){
+				cons = aliyunUrl;
+			}else if (url.contains("http://gangwan-app.oss-cn-hangzhou.aliyuncs.com")){
+				cons = "http://gangwan-app.oss-cn-hangzhou.aliyuncs.com";
+			}else {
+				cons = aliDownloadUrl;
+			}
+			final String[] arr = url.split(cons + "/");
+			String key = arr[1];
+			OSSClientUtil ossClientUtil = new OSSClientUtil();
+			if(StringUtils.isNotBlank(key)){
+				ossClientUtil.deleteSingleObject(key);
+				workattachmentService.delete(workattachment);
+			}
+		}
+	}
+	public List<Workattachment> findAttachment(WorkVisa workVisa) {
+		List<Workattachment>  workattachmentList = new ArrayList<>();
+		if(workVisa != null){
+			String attachmentId = workVisa.getId();
+			if(StringUtils.isNotBlank(attachmentId)){
+				workattachmentList = workVisaDao.getListOfAttachment(attachmentId);
+			}
+		}
+		return workattachmentList ;
+	}
+	//上传
+	@Transactional(readOnly = false)
+	public void uploadattachment(MultipartFile file,WorkVisa workVisa) {
+		if (!file.isEmpty() && file.getSize() > 0) {
+			OSSClientUtil ossClientUtil = new OSSClientUtil();
+			String fileName = file.getOriginalFilename();
+			String fileType = fileName.substring(fileName.lastIndexOf(".") + 1);
+			String url = ossClientUtil.uploadFile2OSS(file, "workVisa");
+			Workattachment workattachment = new Workattachment();
+			workattachment.setUrl(url);
+			workattachment.setType(fileType);
+			workattachment.setAttachmentName(fileName);
+			workattachment.setAttachmentUser(UserUtils.getUser().getId());
+			workattachment.setAttachmentId(workVisa.getId());
+			workattachment.setAttachmentFlag("37");
+			workattachmentService.save(workattachment);
+		}
+	}
+}

+ 688 - 0
src/main/java/com/jeeplus/modules/workvisa/web/WorkVisaController.java

@@ -0,0 +1,688 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workvisa.web;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.validation.ConstraintViolationException;
+
+import com.jeeplus.modules.act.entity.Act;
+import com.jeeplus.modules.act.service.ActTaskService;
+import com.jeeplus.modules.act.utils.ActUtils;
+import com.jeeplus.modules.sys.entity.Office;
+import com.jeeplus.modules.sys.entity.Role;
+import com.jeeplus.modules.sys.entity.User;
+import com.jeeplus.modules.sys.service.OfficeService;
+import com.jeeplus.modules.sys.utils.UserUtils;
+import com.jeeplus.modules.workactivity.entity.Activity;
+import com.jeeplus.modules.workactivity.service.ActivityService;
+import com.jeeplus.modules.workbidproject.entity.WorkBidProject;
+import org.activiti.engine.HistoryService;
+import org.activiti.engine.RepositoryService;
+import org.activiti.engine.RuntimeService;
+import org.activiti.engine.history.HistoricProcessInstance;
+import org.activiti.engine.runtime.ProcessInstance;
+import org.activiti.engine.task.Task;
+import org.springframework.web.multipart.MultipartHttpServletRequest;
+import com.jeeplus.common.utils.IdGen;
+import com.jeeplus.modules.sys.entity.Workattachment;
+import com.jeeplus.modules.sys.service.WorkattachmentService;
+import com.jeeplus.modules.workfullmanage.service.WorkFullManageService;
+import org.apache.shiro.authz.annotation.Logical;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.servlet.mvc.support.RedirectAttributes;
+
+import com.jeeplus.modules.workfullmanage.entity.WorkFullManage;
+import com.google.common.collect.Lists;
+import com.jeeplus.common.utils.DateUtils;
+import com.jeeplus.common.utils.MyBeanUtils;
+import com.jeeplus.common.config.Global;
+import com.jeeplus.common.persistence.Page;
+import com.jeeplus.common.web.BaseController;
+import com.jeeplus.common.utils.StringUtils;
+import com.jeeplus.common.utils.excel.ExportExcel;
+import com.jeeplus.common.utils.excel.ImportExcel;
+import com.jeeplus.modules.workvisa.entity.WorkVisa;
+import com.jeeplus.modules.workvisa.service.WorkVisaService;
+
+/**
+ * 工程签证Controller
+ * @author liuw
+ * @version 2017-10-31
+ */
+@Controller
+@RequestMapping(value = "${adminPath}/workvisa/workVisa")
+public class WorkVisaController extends BaseController {
+
+	@Autowired
+	private WorkVisaService workVisaService;
+	@Autowired
+	private WorkFullManageService workFullManageService;
+	@Autowired
+	private WorkattachmentService workattachmentService;
+	@Autowired
+	private ActTaskService actTaskService;
+	@Autowired
+	private OfficeService officeService;
+	@Autowired
+	private HistoryService historyService;
+	@Autowired
+	private ActivityService activityService;
+
+	@Autowired
+	private RepositoryService repositoryService;
+	@Autowired
+	private RuntimeService runtimeService;
+
+	@ModelAttribute
+	public WorkVisa get(@RequestParam(required=false) String id) {
+		WorkVisa entity = null;
+		if (StringUtils.isNotBlank(id)){
+			entity = workVisaService.get(id);
+		}
+		if (entity == null){
+			entity = new WorkVisa();
+		}
+		return entity;
+	}
+	
+	/**
+	 * 工程签证列表页面
+	 */
+	//@RequiresPermissions("workvisa:workVisa:list")
+	@RequestMapping(value = {"list", ""})
+	public String list(WorkVisa workVisa, HttpServletRequest request, HttpServletResponse response, Model model) {
+		workVisa.setCompanyId(UserUtils.getSelectCompany().getId());
+		Page<WorkVisa> page = workVisaService.findPage(new Page<WorkVisa>(request, response), workVisa);
+		List<WorkVisa> list = page.getList();
+		List<WorkVisa> list2 = new ArrayList<WorkVisa>();
+		for (WorkVisa entity :list){
+			boolean state = true;
+			if(StringUtils.isNotBlank(entity.getProcessInstanceId())){
+				state = actTaskService.isProcessEnd(entity.getProcessInstanceId());
+			}else{
+				state = false;
+			}
+			entity.setProcessEnded(state);
+			list2.add(entity);
+		}
+		page.setList(list2);
+		model.addAttribute("page", page);
+		return "modules/workvisa/workVisaList";
+	}
+	/**
+	 * 工单执行(完成任务)
+	 * @param workVisa
+	 * @param model
+	 * @return
+	 */
+	@RequestMapping(value = "saveAudit")
+	public String saveAudit(WorkVisa workVisa,Map<String, Object> vars, Model model, RedirectAttributes redirectAttributes,HttpServletRequest request) {
+		/*if (org.apache.commons.lang3.StringUtils.isBlank(workVisa.getAct().getComment())){
+			addMessage(model, "请填写审核意见。");
+			return form(workVisa, model,request);
+		}*/
+		String str = workVisaService.auditSave(workVisa);
+		WorkFullManage w = new WorkFullManage();
+		WorkFullManage w1 = workVisa.getFullManage();
+		w.setId(w1.getId());
+		model.addAttribute("workFullManage", w);
+		addMessage(redirectAttributes, str);
+		return "redirect:"+Global.getAdminPath()+"/workvisamanage/workVisaManage/?repage";
+	}
+	/**
+	 * 查看,增加,编辑工程签证表单页面
+	 */
+	//@RequiresPermissions(value={"workvisa:workVisa:view","workvisa:workVisa:add","workvisa:workVisa:edit"},logical=Logical.OR)
+	@RequestMapping(value = "form")
+	public String form(WorkVisa workVisa, Model model,HttpServletRequest request) {
+
+		String wf=request.getParameter("wf");
+		if(wf!=null){
+			WorkFullManage workF = workFullManageService.getWF(wf);
+			model.addAttribute("workFullManage", workF);
+		}
+		List<Workattachment> attachmentList = workVisaService.findAttachment(workVisa);
+		model.addAttribute("workAttachmentList", attachmentList);
+		model.addAttribute("workVisa", workVisa);
+		if (workVisa.getAct()!=null && StringUtils.isNotBlank(workVisa.getAct().getTaskId())){
+			return "modules/workvisa/workVisaAudit";
+		}
+		if(StringUtils.isNotBlank(workVisa.getName()) && workVisa.getName().equals("view")){
+			return "modules/workvisa/workVisaView";
+		}
+		if (StringUtils.isBlank(workVisa.getId())){
+			workVisa.setVisaNumber( IdGen.uuid());
+		}
+		return "modules/workvisa/workVisaForm";
+	}
+
+	/**
+	 * 保存工程签证
+	 */
+	//@RequiresPermissions(value={"workvisa:workVisa:add","workvisa:workVisa:edit"},logical=Logical.OR)
+	@RequestMapping(value = "save")
+	public String save(WorkVisa workVisa, Model model, RedirectAttributes redirectAttributes,HttpServletRequest request) throws Exception{
+		if (!beanValidator(model, workVisa)){
+			return form(workVisa, model,request);
+		}
+		if(!workVisa.getIsNewRecord()){//编辑表单保存
+			WorkVisa t = workVisaService.get(workVisa.getId());//从数据库取出记录的值
+			MyBeanUtils.copyBeanNotNull2Bean(workVisa, t);//将编辑表单中的非NULL值覆盖数据库记录中的值
+			t.setCompanyId(UserUtils.getSelectCompany().getId());
+			String remarks = t.getRemarks();
+			if(StringUtils.isNotBlank(remarks) && remarks.equals("重新申请")){
+			//if (StringUtils.isNotBlank(t.getStatus()) &&t.getStatus().equals("3")){
+				String processInstanceId = t.getProcessInstanceId();
+				HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
+				if(historicProcessInstance!=null) {
+					t.setHistoricProcessInstance(historicProcessInstance);
+					t.setProcessDefinition(repositoryService.createProcessDefinitionQuery().processDefinitionId(historicProcessInstance.getProcessDefinitionId()).singleResult());
+				} else {
+					ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).active().singleResult();
+					if (processInstance != null){
+						t.setProcessInstance(processInstance);
+						t.setProcessDefinition(repositoryService.createProcessDefinitionQuery().processDefinitionId(processInstance.getProcessDefinitionId()).singleResult());
+					}
+				}
+				ProcessInstance processInstance = actTaskService.getProcIns(t.getProcessInstanceId());
+				if (processInstance!=null) {
+					Task taskInfok = actTaskService.getCurrentTaskInfo(processInstance);
+					Act act = new Act();
+					act.setTaskId(taskInfok.getId());
+					act.setTaskName(taskInfok.getName());
+					act.setTaskDefKey(taskInfok.getTaskDefinitionKey());
+					act.setProcDefId(taskInfok.getProcessDefinitionId());
+					act.setProcInsId(taskInfok.getProcessInstanceId());
+					act.setTask(taskInfok);
+					act.setFlag("yes");
+					t.setAct(act);
+				}
+				t.setRemarks("");
+				workVisaService.auditSave(t);
+				workVisaService.save(t);//保存
+				List<Workattachment> list = workVisa.getWorkAttachments();
+				if(list!=null && list.size()>0){
+					for (int i = 0; i < list.size(); i++) {
+						Workattachment w = list.get(i);
+						if (StringUtils.isNotBlank(w.getUrl()) && !w.getUrl().equals("null")){
+							w.setAttachmentId(workVisa.getId());
+							w.setCompanyId(workVisa.getCompanyId());
+							w.setAttachmentUser(UserUtils.getUser().getId());
+							w.setId("");
+							workattachmentService.save(w);
+						}
+					}
+				}
+				addMessage(redirectAttributes, "工程签证单已重新申请!");
+			}else {
+				workVisaService.save(t);//保存
+				List<Workattachment> list = workVisa.getWorkAttachments();
+				if(list!=null && list.size()>0){
+					for (int i = 0; i < list.size(); i++) {
+						Workattachment w = list.get(i);
+						if (StringUtils.isNotBlank(w.getUrl()) && !w.getUrl().equals("null")){
+							w.setAttachmentId(workVisa.getId());
+							w.setCompanyId(workVisa.getCompanyId());
+							w.setAttachmentUser(UserUtils.getUser().getId());
+							w.setId("");
+							workattachmentService.save(w);
+						}
+					}
+				}
+				addMessage(redirectAttributes, "修改工程签证成功");
+			}
+		}else{//新增表单保存
+			workVisa.setStatus("2");
+			workVisa.setCompanyId(UserUtils.getSelectCompany().getId());
+			workVisa.setOfficeId(UserUtils.getSelectOffice().getId());
+			workVisaService.save(workVisa);//保存
+			List<Workattachment> list = workVisa.getWorkAttachments();
+			if(list!=null && list.size()>0){
+				for (int i = 0; i < list.size(); i++) {
+					Workattachment w = list.get(i);
+					if (StringUtils.isNotBlank(w.getUrl()) && !w.getUrl().equals("null")){
+						w.setAttachmentId(workVisa.getId());
+						w.setCompanyId(workVisa.getCompanyId());
+						w.setAttachmentUser(UserUtils.getUser().getId());
+						w.setId("");
+						workattachmentService.save(w);
+					}
+				}
+			}
+
+			Map<String, Object> variables = new HashMap<String, Object>();
+			workVisaService.startProcess(workVisa,variables);
+			addMessage(redirectAttributes, "保存工程签证成功");
+		}
+		return "redirect:"+Global.getAdminPath()+"/workvisamanage/workVisaManage/?repage";
+	}
+	/**
+	 * 保存资格预审项目
+	 */
+	@RequestMapping(value = "store")
+	public String store(WorkVisa workVisa, Model model, RedirectAttributes redirectAttributes,HttpServletRequest request, @RequestParam("attachment_file") MultipartFile attachment_file) throws Exception{
+		if (!beanValidator(model, workVisa)){
+			return form(workVisa, model,request);
+		}
+		if(!workVisa.getIsNewRecord()){//编辑表单保存
+			WorkVisa t = workVisaService.get(workVisa.getId());//从数据库取出记录的值
+			MyBeanUtils.copyBeanNotNull2Bean(workVisa, t);//将编辑表单中的非NULL值覆盖数据库记录中的值
+			t.setCompanyId(UserUtils.getSelectCompany().getId());
+
+			if (StringUtils.isNotBlank(t.getStatus()) &&t.getStatus().equals("3")){
+				String processInstanceId = t.getProcessInstanceId();
+				HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
+				if(historicProcessInstance!=null) {
+					t.setHistoricProcessInstance(historicProcessInstance);
+					t.setProcessDefinition(repositoryService.createProcessDefinitionQuery().processDefinitionId(historicProcessInstance.getProcessDefinitionId()).singleResult());
+				} else {
+					ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).active().singleResult();
+					if (processInstance != null){
+						t.setProcessInstance(processInstance);
+						t.setProcessDefinition(repositoryService.createProcessDefinitionQuery().processDefinitionId(processInstance.getProcessDefinitionId()).singleResult());
+					}
+				}
+				ProcessInstance processInstance = actTaskService.getProcIns(t.getProcessInstanceId());
+				if (processInstance!=null) {
+					Task taskInfok = actTaskService.getCurrentTaskInfo(processInstance);
+					Act act = new Act();
+					act.setTaskId(taskInfok.getId());
+					act.setTaskName(taskInfok.getName());
+					act.setTaskDefKey(taskInfok.getTaskDefinitionKey());
+					act.setProcDefId(taskInfok.getProcessDefinitionId());
+					act.setProcInsId(taskInfok.getProcessInstanceId());
+					act.setTask(taskInfok);
+					act.setFlag("no");
+					t.setAct(act);
+				}
+				workVisaService.auditSave(t);
+				workVisaService.save(t);//保存
+				List<Workattachment> list = workVisa.getWorkAttachments();
+				if(list!=null && list.size()>0){
+					for (int i = 0; i < list.size(); i++) {
+						Workattachment w = list.get(i);
+						if (StringUtils.isNotBlank(w.getUrl()) && !w.getUrl().equals("null")){
+							w.setAttachmentId(workVisa.getId());
+							w.setCompanyId(workVisa.getCompanyId());
+							w.setAttachmentUser(UserUtils.getUser().getId());
+							w.setId("");
+							workattachmentService.save(w);
+						}
+					}
+				}
+				addMessage(redirectAttributes, "工程签证单已撤销!");
+			}else {
+				workVisaService.save(t);//保存
+				List<Workattachment> list = workVisa.getWorkAttachments();
+				if(list!=null && list.size()>0){
+					for (int i = 0; i < list.size(); i++) {
+						Workattachment w = list.get(i);
+						if (StringUtils.isNotBlank(w.getUrl()) && !w.getUrl().equals("null")){
+							w.setAttachmentId(workVisa.getId());
+							w.setCompanyId(workVisa.getCompanyId());
+							w.setAttachmentUser(UserUtils.getUser().getId());
+							w.setId("");
+							workattachmentService.save(w);
+						}
+					}
+				}
+				addMessage(redirectAttributes, "修改工程签证成功");
+			}
+		}else{//新增表单保存
+			workVisa.setStatus("1");
+			workVisa.setCompanyId(UserUtils.getSelectCompany().getId());
+			workVisa.setOfficeId(UserUtils.getSelectOffice().getId());
+			workVisaService.save(workVisa);//保存
+			List<Workattachment> list = workVisa.getWorkAttachments();
+			if(list!=null && list.size()>0){
+				for (int i = 0; i < list.size(); i++) {
+					Workattachment w = list.get(i);
+					if (StringUtils.isNotBlank(w.getUrl()) && !w.getUrl().equals("null")){
+						w.setAttachmentId(workVisa.getId());
+						w.setCompanyId(workVisa.getCompanyId());
+						w.setAttachmentUser(UserUtils.getUser().getId());
+						w.setId("");
+						workattachmentService.save(w);
+					}
+				}
+			}
+
+			addMessage(redirectAttributes, "暂存工程签证成功");
+		}
+		return "redirect:"+Global.getAdminPath()+"/workvisamanage/workVisaManage/?repage";
+	}
+	/**
+	 * 删除工程签证
+	 */
+	//@RequiresPermissions("workvisamanage:workVisaManage:list")
+	//@RequiresPermissions("workvisa:workVisa:del")
+	@RequestMapping(value = "delete")
+	public String delete(WorkVisa workVisa, RedirectAttributes redirectAttributes) {
+		workVisaService.delete(workVisa);
+		List<Workattachment> attachmentList = workVisaService.findAttachment(workVisa);
+		for(Workattachment workattachment:attachmentList){
+			if(workVisa != null && workVisa.getId() != null){
+				workVisaService.deleteFileFromAliyun(workattachment);
+			}
+		}
+		addMessage(redirectAttributes, "删除工程签证成功");
+		return "redirect:"+Global.getAdminPath()+"/workvisamanage/workVisaManage/workVisaList";
+		//return "redirect:"+Global.getAdminPath()+"/workvisamanage/workVisaManage/list";
+	}
+	
+	/**
+	 * 批量删除工程签证
+	 */
+	//@RequiresPermissions("workvisa:workVisa:del")
+	@RequestMapping(value = "deleteAll")
+	public String deleteAll(String ids, RedirectAttributes redirectAttributes) {
+		String idArray[] =ids.split(",");
+		for(String id : idArray){
+			workVisaService.delete(workVisaService.get(id));
+		}
+		addMessage(redirectAttributes, "删除工程签证成功");
+		return "redirect:"+Global.getAdminPath()+"/workvisa/workVisa/?repage";
+	}
+	
+	/**
+	 * 导出excel文件
+	 */
+	@RequiresPermissions("workvisa:workVisa:export")
+    @RequestMapping(value = "export", method=RequestMethod.POST)
+    public String exportFile(WorkVisa workVisa, HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) {
+		try {
+            String fileName = "工程签证"+DateUtils.getDate("yyyyMMddHHmmss")+".xlsx";
+            Page<WorkVisa> page = workVisaService.findPage(new Page<WorkVisa>(request, response, -1), workVisa);
+    		new ExportExcel("工程签证", WorkVisa.class).setDataList(page.getList()).write(response, fileName).dispose();
+    		return null;
+		} catch (Exception e) {
+			addMessage(redirectAttributes, "导出工程签证记录失败!失败信息:"+e.getMessage());
+		}
+		return "redirect:"+Global.getAdminPath()+"/workvisa/workVisa/?repage";
+    }
+
+	/**
+	 * 导入Excel数据
+
+	 */
+	@RequiresPermissions("workvisa:workVisa:import")
+    @RequestMapping(value = "import", method=RequestMethod.POST)
+    public String importFile(MultipartFile file, RedirectAttributes redirectAttributes) {
+		try {
+			int successNum = 0;
+			int failureNum = 0;
+			StringBuilder failureMsg = new StringBuilder();
+			ImportExcel ei = new ImportExcel(file, 1, 0);
+			List<WorkVisa> list = ei.getDataList(WorkVisa.class);
+			for (WorkVisa workVisa : list){
+				try{
+					workVisaService.save(workVisa);
+					successNum++;
+				}catch(ConstraintViolationException ex){
+					failureNum++;
+				}catch (Exception ex) {
+					failureNum++;
+				}
+			}
+			if (failureNum>0){
+				failureMsg.insert(0, ",失败 "+failureNum+" 条工程签证记录。");
+			}
+			addMessage(redirectAttributes, "已成功导入 "+successNum+" 条工程签证记录"+failureMsg);
+		} catch (Exception e) {
+			addMessage(redirectAttributes, "导入工程签证失败!失败信息:"+e.getMessage());
+		}
+		return "redirect:"+Global.getAdminPath()+"/workvisa/workVisa/?repage";
+    }
+	
+	/**
+	 * 下载导入工程签证数据模板
+	 */
+	@RequiresPermissions("workvisa:workVisa:import")
+    @RequestMapping(value = "import/template")
+    public String importFileTemplate(HttpServletResponse response, RedirectAttributes redirectAttributes) {
+		try {
+            String fileName = "工程签证数据导入模板.xlsx";
+    		List<WorkVisa> list = Lists.newArrayList(); 
+    		new ExportExcel("工程签证数据", WorkVisa.class, 1).setDataList(list).write(response, fileName).dispose();
+    		return null;
+		} catch (Exception e) {
+			addMessage(redirectAttributes, "导入模板下载失败!失败信息:"+e.getMessage());
+		}
+		return "redirect:"+Global.getAdminPath()+"/workvisa/workVisa/?repage";
+    }
+	
+	
+	/**
+	 * 选择全过程管理项目
+	 */
+	@RequestMapping(value = "selectfullManage")
+	public String selectfullManage(WorkFullManage fullManage, String url, String fieldLabels, String fieldKeys, String searchLabel, String searchKey, HttpServletRequest request, HttpServletResponse response, Model model) {
+		Page<WorkFullManage> page = workVisaService.findPageByfullManage(new Page<WorkFullManage>(request, response),  fullManage);
+		try {
+			fieldLabels = URLDecoder.decode(fieldLabels, "UTF-8");
+			fieldKeys = URLDecoder.decode(fieldKeys, "UTF-8");
+			searchLabel = URLDecoder.decode(searchLabel, "UTF-8");
+			searchKey = URLDecoder.decode(searchKey, "UTF-8");
+		} catch (UnsupportedEncodingException e) {
+			e.printStackTrace();
+		}
+		model.addAttribute("labelNames", fieldLabels.split("\\|"));
+		model.addAttribute("labelValues", fieldKeys.split("\\|"));
+		model.addAttribute("fieldLabels", fieldLabels);
+		model.addAttribute("fieldKeys", fieldKeys);
+		model.addAttribute("url", url);
+		model.addAttribute("searchLabel", searchLabel);
+		model.addAttribute("searchKey", searchKey);
+		model.addAttribute("obj", fullManage);
+		model.addAttribute("page", page);
+		return "modules/sys/gridselect";
+	}
+
+	/**
+	 * 上传附件
+	 * @param multiRequest
+	 * @return
+	 */
+	@RequestMapping("/evaluateUpload")
+	@ResponseBody
+	public String evaluateUpload(MultipartHttpServletRequest multiRequest){
+		String title = multiRequest.getParameter("title");
+		String userId = multiRequest.getParameter("id");
+
+		workVisaService.uploadEvaludate(multiRequest);
+
+		return title;
+	}
+	/**
+	 *  单个删除阿里云上的文件,同时更新相关对象的附件信息
+	 *  阿里云文件地址http://gangwan-app.oss-cn-hangzhou.aliyuncs.com/attachment-file/workBidingDocument/3fcf03e37b3ba0fd5c7821998e392395.doc
+	 *  其中阿里云删除接口所需的参数 key 指的是 attachment-file/workBidingDocument/3fcf03e37b3ba0fd5c7821998e392395.doc
+	 * @return
+	 */
+	@RequestMapping("/deleteFileFromAliyun")
+	public String deleteFileFromAliyun(@RequestParam("attachmentId") String attachmentId,WorkVisa workVisa,Model model,HttpServletRequest request){
+		Workattachment workattachment = workattachmentService.get(attachmentId);
+		if(workVisa != null && workVisa.getId() != null){
+			workVisaService.deleteFileFromAliyun(workattachment);
+		}
+		return "redirect:"+Global.getAdminPath()+"/workvisamanage/workVisaManage/workVisaList";
+	}
+
+	/**
+	 * 待办任务列表页面
+	 * @param request
+	 * @param response
+	 * @param model
+	 * @return
+	 */
+	@RequestMapping(value = {"workVisaTodoList"})
+	public String workVisaTodoList(Act act, HttpServletRequest request, HttpServletResponse response, Model model) {
+		act.setProcDefKey("workVisa");
+		List<Act> list = new ArrayList<>();
+		list.addAll(actTaskService.todoList(act));
+		Office office = UserUtils.getSelectCompany();
+		String companyId = office==null?"":office.getId();
+		List<Activity> activities = activityService.groupByActivityMenu("9574872f45b84acd89jjj1e66a3db2c8",companyId);
+		for (Activity activity:activities){
+			act.setProcDefKey(activity.getProcessKey());
+			list.addAll(actTaskService.todoList(act));
+		}
+		List<WorkVisa> lists = new ArrayList<WorkVisa>();
+		Role role = UserUtils.getSelectRole().get(0);
+		String officeId = "";
+		if (role.getDataScope().contains("4")){
+			User user = UserUtils.getUser();
+			officeId = user.getOffice().getId();
+		}
+		for (Act a : list) {
+			WorkVisa workVisa = workVisaService.getByProcessInstanceId(a.getTask().getProcessInstanceId());
+			if (workVisa != null && workVisa.getCompanyId().equals(companyId) && workVisa.getStatus() !=null && workVisa.getStatus().equals("2")) {
+				User createBy = UserUtils.get(workVisa.getCreateBy().getId());
+				if (StringUtils.isNotBlank(officeId)){
+					if (officeId.equals(createBy.getOffice().getId())){
+						if (a.getVars().getMap().get("applyUserId")!=null) {
+							User user = UserUtils.get(a.getVars().getMap().get("applyUserId").toString());
+							if (user != null) {
+								a.getVars().getMap().put("applyUserId", UserUtils.get(a.getVars().getMap().get("applyUserId").toString()).getName());
+							}
+						}
+						workVisa.setAct(a);
+						/*if (com.jeeplus.common.utils.StringUtils.isNotBlank(workVisa.getId())){
+							workVisa.setName(officeService.get(companyId).getName());
+						}*/
+						lists.add(workVisa);
+					}
+				}else {
+					if (a.getVars().getMap().get("applyUserId")!=null) {
+						User user = UserUtils.get(a.getVars().getMap().get("applyUserId").toString());
+						if (user != null) {
+							a.getVars().getMap().put("applyUserId", UserUtils.get(a.getVars().getMap().get("applyUserId").toString()).getName());
+						}
+					}
+					workVisa.setAct(a);
+					/*if (com.jeeplus.common.utils.StringUtils.isNotBlank(workVisa.getId())){
+						workVisa.setName(officeService.get(companyId).getName());
+					}*/
+					lists.add(workVisa);
+				}
+			}
+		}
+		model.addAttribute("list", lists);
+		return "modules/workvisa/workVisaTodoList";
+	}
+
+	/**
+	 * 已办任务
+	 * @param act
+	 * @param request
+	 * @param response
+	 * @param model
+	 * @return
+	 */
+	@RequestMapping(value = {"workVisaHistoricList"})
+	public String workVisaHistoricList (Act act, HttpServletRequest request, HttpServletResponse response, Model model){
+		act.setProcDefKey("workVisa");
+		List<Act> list = actTaskService.historicList(act);
+		Office office = UserUtils.getSelectCompany();
+		String companyId = office==null?"":office.getId();
+		List<Activity> activities = activityService.groupByActivityMenu("9574872f45b84acd89jjj1e66a3db2c8",companyId);
+		for (Activity activity:activities){
+			act.setProcDefKey(activity.getProcessKey());
+			list.addAll(actTaskService.historicList(act));
+		}
+		List<WorkVisa> lists = new ArrayList<WorkVisa>();
+		for (Act a : list) {
+			try {
+				WorkVisa workVisa = workVisaService.getByProcessInstanceId(a.getHistTask().getProcessInstanceId());
+				if (workVisa != null && workVisa.getCompanyId().equals(companyId)) {
+					if (a.getVars().getMap().get("applyUserId")!=null){
+						a.getVars().getMap().put("applyUserId",UserUtils.get(a.getVars().getMap().get("applyUserId").toString()).getName());
+					}
+					workVisa.setAct(a);
+				/*	if (com.jeeplus.common.utils.StringUtils.isNotBlank(workEngineeringProject.getId())){
+						workVisa.setName(officeService.get(companyId).getName());
+					}*/
+					lists.add(workVisa);
+				}
+			}catch (Exception e){
+				logger.info("Exception e"+e);
+			}
+		}
+		model.addAttribute("list", lists);
+
+		return "modules/workvisa/workVisaHistoricList";
+	}
+
+	/**
+	 * 审核信息
+	 * @param response
+	 * @param model
+	 * @return
+	 */
+	@RequestMapping(value = "applyOnWorkBidProject")
+	public String applyOnWorkBidProject(Act act, HttpServletResponse response, Model model) {
+		// 获取流程XML上的表单KEY
+		String formKey = "/workvisa/workVisa/form";
+		//logger.info("------formKeys:"+formKeys);
+		// 获取流程实例对象
+		if (act.getProcInsId() != null){
+			if(actTaskService.getProcIns(act.getProcInsId())!=null){
+				act.setProcIns(actTaskService.getProcIns(act.getProcInsId()));
+			}else{
+				act.setFinishedProcIns(actTaskService.getFinishedProcIns(act.getProcInsId()));
+			}
+		}
+		return "redirect:" + ActUtils.getFormUrl(formKey, act);
+	}
+
+	/**
+	 * 读取所有流程
+	 * @return
+	 */
+	@RequestMapping(value = "getProcess")
+	public String getProcess(WorkVisa workVisa, HttpServletRequest request, HttpServletResponse response, Model model) {
+		//admin 可以查看所有流程  展示注释
+//        User user = UserUtils.getUser();
+//        if (!user.isAdmin()){
+////            leave.setCompanyId(user.getComId());
+//            if (!UserUtils.isManager()){
+//                workReimbursement.setCreateBy(user);
+//            }
+//        }
+		WorkVisa workVisa1 = workVisaService.get(workVisa.getId());
+		model.addAttribute("processInstanceId", workVisa1.getProcessInstanceId());
+		return "modules/workvisa/workVisaTask";
+	}
+
+	/**
+	 * 启动流程
+	 * @return
+	 */
+	@RequestMapping(value = "startposs")
+	public String startposs(WorkVisa workVisa, HttpServletRequest request, HttpServletResponse response, Model model, RedirectAttributes redirectAttributes)throws Exception {
+		Map<String, Object> variables = new HashMap<String, Object>();
+		WorkVisa t = workVisaService.get(workVisa.getId());//从数据库取出记录的值
+		MyBeanUtils.copyBeanNotNull2Bean(workVisa, t);//将编辑表单中的非NULL值覆盖数据库记录中的值
+		t.setStatus("2");
+		t.preUpdate();
+		workVisaService.update(t);
+		workVisaService.startProcess(t,variables);
+		addMessage(redirectAttributes, "启动流程成功");
+		//return "redirect:"+Global.getAdminPath()+"/workvisamanage/workVisaManage/?repage";
+		return "redirect:"+Global.getAdminPath()+"/workvisamanage/workVisaManage/workVisaList";
+	}
+}

+ 148 - 0
src/main/java/com/jeeplus/modules/workvisa/web/WorkVisaManageController.java

@@ -0,0 +1,148 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.workvisa.web;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.jeeplus.common.config.Global;
+import com.jeeplus.common.mapper.JsonMapper;
+import com.jeeplus.common.persistence.Page;
+import com.jeeplus.common.utils.DateUtils;
+import com.jeeplus.common.utils.MyBeanUtils;
+import com.jeeplus.common.utils.StringUtils;
+import com.jeeplus.common.utils.excel.ExportExcel;
+import com.jeeplus.common.utils.excel.ImportExcel;
+import com.jeeplus.common.web.BaseController;
+import com.jeeplus.modules.act.service.ActTaskService;
+import com.jeeplus.modules.sys.entity.Role;
+import com.jeeplus.modules.sys.utils.DictUtils;
+import com.jeeplus.modules.sys.utils.UserUtils;
+import com.jeeplus.modules.workclientinfo.entity.WorkClientInfo;
+import com.jeeplus.modules.workclientinfo.entity.WorkClientLinkman;
+import com.jeeplus.modules.workclientinfo.service.WorkClientInfoService;
+import com.jeeplus.modules.workcontractinfo.entity.WorkContractInfo;
+import com.jeeplus.modules.workcontractinfo.service.WorkContractInfoService;
+import com.jeeplus.modules.workfullmanage.entity.WorkFullManage;
+import com.jeeplus.modules.workfullmanage.service.WorkFullManageService;
+import com.jeeplus.modules.workvisa.entity.WorkVisa;
+import com.jeeplus.modules.workvisa.service.WorkVisaService;
+import org.apache.shiro.authz.annotation.Logical;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.servlet.mvc.support.RedirectAttributes;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import javax.validation.ConstraintViolationException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+/**
+ * 工程签证管理Controller
+ * @author
+ * @version
+ */
+@Controller
+@RequestMapping(value = "${adminPath}/workvisamanage/workVisaManage")
+public class WorkVisaManageController extends BaseController {
+
+	@Autowired
+	private WorkFullManageService workFullManageService;
+	@Autowired
+	private ActTaskService actTaskService;
+
+	@Autowired
+	private WorkVisaService workVisaService;
+	@ModelAttribute
+	public WorkFullManage get(@RequestParam(required=false) String id) {
+		WorkFullManage entity = null;
+		if (StringUtils.isNotBlank(id)){
+			entity = workFullManageService.get(id);
+		}
+		if (entity == null){
+			entity = new WorkFullManage();
+		}
+		return entity;
+	}
+	
+	/**
+	 * 项目列表页面
+	 */
+	@RequiresPermissions("workvisamanage:workVisaManage:list")
+	@RequestMapping(value = {"list", ""})
+	public String list(WorkFullManage workFullManage, HttpServletRequest request, HttpServletResponse response, Model model) {
+		if(!UserUtils.getSelectRoleInfo()){
+			String id = UserUtils.getUser().getId();
+			workFullManage.setQueryCon(id);
+			workFullManage.setMasterId(UserUtils.getUser().getId());
+		}
+		Page<WorkFullManage> page = workFullManageService.findPage(new Page<WorkFullManage>(request, response), workFullManage);
+		List<WorkFullManage> list = page.getList();
+
+		if(list.size()!=0) {
+			for (WorkFullManage w : list) {
+				StringBuffer sb =new StringBuffer();
+				String hostM = w.getHostMaster();
+				String[] hostMaster = hostM.split("\\,");
+				for (int i = 0; i < hostMaster.length; i++) {
+					String hostMasterName = UserUtils.get(hostMaster[i]).getName();
+					if(sb.length()==0){
+						sb.append(hostMasterName);
+					}else{
+						sb.append(","+hostMasterName);
+					}
+				}
+				w.setWorkVisaCount(workVisaService.findCount(w.getId())+"");
+				w.setHostMasterName(new String(sb));
+			}
+		}
+		model.addAttribute("page", page);
+		return "modules/workvisa/workVisaManageList";
+	}
+	/**
+	 * 查看
+	 */
+	//@RequiresPermissions(value={"workfullmanage:workFullManage:view"},logical=Logical.OR)
+	@RequestMapping(value = "form")
+	public String form(WorkFullManage workFullManage, Model model) {
+		String view = "workFullManageFormDetail";
+		model.addAttribute("workFullManage", workFullManage);
+		return "modules/workvisa/"+view;
+	}
+	/**
+	 * 工程签证列表
+	 */
+	@RequestMapping(value = "workVisaList")
+	public String workVisaList(HttpServletRequest request, HttpServletResponse response, Model model, HttpSession session) {
+		String wf=request.getParameter("wf");
+		if(wf==null){
+			wf=session.getAttribute("wf").toString();
+		}
+		session.setAttribute("wf",wf);
+		WorkFullManage workFullManage = new WorkFullManage();
+		workFullManage.setId(wf);
+		WorkVisa workVisa = new WorkVisa();
+		workVisa.setFullManage(workFullManage);
+		Page<WorkVisa> page = workVisaService.findPageByfullMg(new Page<WorkVisa>(request, response),workVisa);
+		List<WorkVisa> list = page.getList();
+		for (WorkVisa entity :list){
+			boolean state = true;
+			if(StringUtils.isNotBlank(entity.getProcessInstanceId())){
+				state = actTaskService.isProcessEnd(entity.getProcessInstanceId());
+			}else{
+				state = false;
+			}
+			entity.setProcessEnded(state);
+		}
+		model.addAttribute("page", page);
+		return "modules/workvisa/workVisaList";
+	}
+
+}